From 08eeb76879a2278f9e61e4d94f7f298571757dc9 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Sat, 28 Apr 2018 14:07:45 +0200 Subject: [PATCH 1/4] Improve consistency of Shared and Permalink blocks UI. --- core-blocks/block/edit-panel/index.js | 20 ++++++++----------- core-blocks/block/edit-panel/style.scss | 4 ---- .../src/components/post-permalink/editor.js | 3 +-- .../src/components/post-permalink/style.scss | 1 + 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/core-blocks/block/edit-panel/index.js b/core-blocks/block/edit-panel/index.js index 24b42a2cdb7230..cf671bcda651a3 100644 --- a/core-blocks/block/edit-panel/index.js +++ b/core-blocks/block/edit-panel/index.js @@ -18,6 +18,7 @@ class ReusableBlockEditPanel extends Component { this.titleField = createRef(); this.editButton = createRef(); + this.editForm = createRef(); this.handleFormSubmit = this.handleFormSubmit.bind( this ); this.handleTitleChange = this.handleTitleChange.bind( this ); this.handleTitleKeyDown = this.handleTitleKeyDown.bind( this ); @@ -35,7 +36,7 @@ class ReusableBlockEditPanel extends Component { if ( ! prevProps.isEditing && this.props.isEditing ) { this.titleField.current.select(); } - // Move focus back to the Edit button after pressing the Escape key, Cancel, or Save. + // Move focus back to the Edit button after pressing the Escape key or after saving. if ( ( prevProps.isEditing || prevProps.isSaving ) && ! this.props.isEditing && ! this.props.isSaving ) { this.editButton.current.focus(); } @@ -58,7 +59,7 @@ class ReusableBlockEditPanel extends Component { } render() { - const { isEditing, title, isSaving, onEdit, onCancel, instanceId } = this.props; + const { isEditing, title, isSaving, onEdit, instanceId } = this.props; return ( @@ -78,7 +79,11 @@ class ReusableBlockEditPanel extends Component { ) } { ( isEditing || isSaving ) && ( -
+
diff --git a/core-blocks/block/edit-panel/style.scss b/core-blocks/block/edit-panel/style.scss index 08b22d1f04b071..44c63538619328 100644 --- a/core-blocks/block/edit-panel/style.scss +++ b/core-blocks/block/edit-panel/style.scss @@ -38,10 +38,6 @@ margin: #{ $item-spacing / 2 } 0 $item-spacing; } - .components-button.reusable-block-edit-panel__button { - margin: 0 5px 0 0; - } - @include break-large() { flex-wrap: nowrap; diff --git a/packages/editor/src/components/post-permalink/editor.js b/packages/editor/src/components/post-permalink/editor.js index 3185fd2abe6ea6..abc51bcf485419 100644 --- a/packages/editor/src/components/post-permalink/editor.js +++ b/packages/editor/src/components/post-permalink/editor.js @@ -71,7 +71,7 @@ class PostPermalinkEditor extends Component { isLarge onClick={ this.onSavePermalink } > - { __( 'OK' ) } + { __( 'Save' ) } ); @@ -91,4 +91,3 @@ export default compose( [ return { editPost }; } ), ] )( PostPermalinkEditor ); - diff --git a/packages/editor/src/components/post-permalink/style.scss b/packages/editor/src/components/post-permalink/style.scss index 30e1600bfd6a06..8740ad31264b6e 100644 --- a/packages/editor/src/components/post-permalink/style.scss +++ b/packages/editor/src/components/post-permalink/style.scss @@ -33,6 +33,7 @@ .editor-post-permalink__label { margin: 0 10px 0 5px; + font-weight: 600; } .editor-post-permalink__link { From 4ae18679ca80dcec31821f8a3b038b5371d74e6b Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Mon, 30 Apr 2018 15:36:01 +0200 Subject: [PATCH 2/4] Better check for the edit form ref, which exist only when isEditing. --- core-blocks/block/edit-panel/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core-blocks/block/edit-panel/index.js b/core-blocks/block/edit-panel/index.js index cf671bcda651a3..96976b649bce4a 100644 --- a/core-blocks/block/edit-panel/index.js +++ b/core-blocks/block/edit-panel/index.js @@ -25,10 +25,11 @@ class ReusableBlockEditPanel extends Component { } componentDidMount() { - // Select the input text when the form opens. - if ( this.props.isEditing && this.titleField.current ) { - this.titleField.current.select(); - } + document.addEventListener( 'click', this.handleClickOutside, true ); + } + + componentWillUnmount() { + document.removeEventListener( 'click', this.handleClickOutside, true ); } componentDidUpdate( prevProps ) { From 1c3eca39183d1c0e7f5a16337a6a37e61503cef5 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Mon, 14 May 2018 14:51:57 +0200 Subject: [PATCH 3/4] Remove click outside behavior. --- core-blocks/block/edit-panel/index.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/core-blocks/block/edit-panel/index.js b/core-blocks/block/edit-panel/index.js index 96976b649bce4a..1e05cc6031ffac 100644 --- a/core-blocks/block/edit-panel/index.js +++ b/core-blocks/block/edit-panel/index.js @@ -24,14 +24,6 @@ class ReusableBlockEditPanel extends Component { this.handleTitleKeyDown = this.handleTitleKeyDown.bind( this ); } - componentDidMount() { - document.addEventListener( 'click', this.handleClickOutside, true ); - } - - componentWillUnmount() { - document.removeEventListener( 'click', this.handleClickOutside, true ); - } - componentDidUpdate( prevProps ) { // Select the input text only once when the form opens. if ( ! prevProps.isEditing && this.props.isEditing ) { From 95167448ca281dd7508ec1e1a4b1cae13fa93118 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 8 Aug 2018 14:39:36 +0200 Subject: [PATCH 4/4] Re-add changes from PR 7987. --- core-blocks/block/edit-panel/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core-blocks/block/edit-panel/index.js b/core-blocks/block/edit-panel/index.js index 1e05cc6031ffac..cf671bcda651a3 100644 --- a/core-blocks/block/edit-panel/index.js +++ b/core-blocks/block/edit-panel/index.js @@ -24,6 +24,13 @@ class ReusableBlockEditPanel extends Component { this.handleTitleKeyDown = this.handleTitleKeyDown.bind( this ); } + componentDidMount() { + // Select the input text when the form opens. + if ( this.props.isEditing && this.titleField.current ) { + this.titleField.current.select(); + } + } + componentDidUpdate( prevProps ) { // Select the input text only once when the form opens. if ( ! prevProps.isEditing && this.props.isEditing ) {