From 8160f88d06891d533fa3609ff685652fea112ca3 Mon Sep 17 00:00:00 2001 From: etoledom Date: Fri, 17 May 2019 10:03:29 +0200 Subject: [PATCH 1/2] Fix rich image caption toolbar and focus (#15685) * RichText: ownProps has precedence over block context. In this way, instances of RichText outside blocks can pass and handle their own custom onFocus and isSelected * RichText: Remove isSelected from block edit context. * Fix lint issues --- .../src/components/rich-text/index.native.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/index.native.js b/packages/block-editor/src/components/rich-text/index.native.js index 9b9af9c49eee8..79fc7c2839fef 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -821,11 +821,14 @@ RichText.defaultProps = { const RichTextContainer = compose( [ withInstanceId, - withBlockEditContext( ( { clientId, onFocus, isSelected, onCaretVerticalPositionChange }, ownProps ) => { + withBlockEditContext( ( { clientId, onFocus, onCaretVerticalPositionChange }, ownProps ) => { + // ownProps.onFocus needs precedence over the block edit context + if ( ownProps.onFocus !== undefined ) { + onFocus = ownProps.onFocus; + } return { clientId, - isSelected, - onFocus: onFocus || ownProps.onFocus, + onFocus, onCaretVerticalPositionChange, }; } ), From 0e05d0c5a0fb4139a21a430d0dbe4a383fa12c60 Mon Sep 17 00:00:00 2001 From: etoledom Date: Fri, 17 May 2019 13:22:08 +0200 Subject: [PATCH 2/2] RichText: Revert removing isSelected from block context (#15698) Removing it generates a regression where inserting a new list block, the block is not selected --- .../block-editor/src/components/rich-text/index.native.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/index.native.js b/packages/block-editor/src/components/rich-text/index.native.js index 79fc7c2839fef..6d2275d8e783e 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -821,12 +821,16 @@ RichText.defaultProps = { const RichTextContainer = compose( [ withInstanceId, - withBlockEditContext( ( { clientId, onFocus, onCaretVerticalPositionChange }, ownProps ) => { - // ownProps.onFocus needs precedence over the block edit context + withBlockEditContext( ( { clientId, onFocus, onCaretVerticalPositionChange, isSelected }, ownProps ) => { + // ownProps.onFocus and isSelected needs precedence over the block edit context + if ( ownProps.isSelected !== undefined ) { + isSelected = ownProps.isSelected; + } if ( ownProps.onFocus !== undefined ) { onFocus = ownProps.onFocus; } return { + isSelected, clientId, onFocus, onCaretVerticalPositionChange,