From e3a82e9bd66e59f52cbf3a04460969afdb802597 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 5 May 2022 18:16:03 +0200 Subject: [PATCH 1/2] Mobile - BlockDraggable - Set isEditingText to false and update it with the initialization of the AztecView listener --- .../src/components/block-draggable/index.native.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/block-draggable/index.native.js b/packages/block-editor/src/components/block-draggable/index.native.js index f291a20edb2f14..6d127782980f8e 100644 --- a/packages/block-editor/src/components/block-draggable/index.native.js +++ b/packages/block-editor/src/components/block-draggable/index.native.js @@ -262,9 +262,7 @@ const BlockDraggableWrapper = ( { children } ) => { */ const BlockDraggable = ( { clientId, children, enabled = true } ) => { const wasBeingDragged = useRef( false ); - const [ isEditingText, setIsEditingText ] = useState( - RCTAztecView.InputState.isFocused() - ); + const [ isEditingText, setIsEditingText ] = useState( false ); const draggingAnimation = { opacity: useSharedValue( 1 ), @@ -327,6 +325,11 @@ const BlockDraggable = ( { clientId, children, enabled = true } ) => { }, [] ); useEffect( () => { + const isAnyAztecInputFocused = RCTAztecView.InputState.isFocused(); + if ( isAnyAztecInputFocused ) { + setIsEditingText( isAnyAztecInputFocused ); + } + RCTAztecView.InputState.addFocusChangeListener( onFocusChangeAztec ); return () => { RCTAztecView.InputState.removeFocusChangeListener( From 695a65bccba66afa9878d7ee14a360163323a932 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Thu, 5 May 2022 18:17:06 +0200 Subject: [PATCH 2/2] Mobile - AztecView - Move notifyInputChange to the focus/blur functions within AztecInputState, to fix an issue where these are called directly. --- packages/react-native-aztec/src/AztecInputState.js | 2 ++ packages/react-native-aztec/src/AztecView.js | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/react-native-aztec/src/AztecInputState.js b/packages/react-native-aztec/src/AztecInputState.js index b0b184c2dd5c6a..973b8179ea5ec9 100644 --- a/packages/react-native-aztec/src/AztecInputState.js +++ b/packages/react-native-aztec/src/AztecInputState.js @@ -90,6 +90,7 @@ export const notifyInputChange = () => { */ export const focus = ( element ) => { TextInputState.focusTextInput( element ); + notifyInputChange(); }; /** @@ -99,6 +100,7 @@ export const focus = ( element ) => { */ export const blur = ( element ) => { TextInputState.blurTextInput( element ); + notifyInputChange(); }; /** diff --git a/packages/react-native-aztec/src/AztecView.js b/packages/react-native-aztec/src/AztecView.js index 3e6193bf10a4b2..280be8783aaacf 100644 --- a/packages/react-native-aztec/src/AztecView.js +++ b/packages/react-native-aztec/src/AztecView.js @@ -122,8 +122,6 @@ class AztecView extends Component { } _onFocus( event ) { - AztecInputState.notifyInputChange(); - if ( ! this.props.onFocus ) { return; } @@ -136,7 +134,6 @@ class AztecView extends Component { this.selectionEndCaretY = null; AztecInputState.blur( this.aztecViewRef.current ); - AztecInputState.notifyInputChange(); if ( ! this.props.onBlur ) { return;