From 8160f88d06891d533fa3609ff685652fea112ca3 Mon Sep 17 00:00:00 2001 From: etoledom Date: Fri, 17 May 2019 10:03:29 +0200 Subject: [PATCH] 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, }; } ),