Skip to content

Commit

Permalink
Mobile - Rich Text - Update _onAztecFocus to take a similar approach to
Browse files Browse the repository at this point in the history
#44988 but taking into account that the input is not currently focused to avoid a focus loop and also to use AztecInputState.focus to trigger the notifyInputChange callback
  • Loading branch information
Gerardo committed Aug 2, 2023
1 parent 88993a1 commit 3956a0d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/react-native-aztec/src/AztecView.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,14 @@ class AztecView extends Component {
}

_onAztecFocus( event ) {
// IMPORTANT: the onFocus events from Aztec are thrown away as these are handled by onPress() in the upper level.
// IMPORTANT: the onFocus events from Aztec are thrown away on Android as these are handled by onPress() in the upper level.
// It's necessary to do this otherwise onFocus may be set by `{...otherProps}` and thus the onPress + onFocus
// combination generate an infinite loop as described in https://github.com/wordpress-mobile/gutenberg-mobile/issues/302
// For iOS, this is necessary to let the system know the current caret data.
// For iOS, this is necessary to let the system know when Aztec was focused programatically.
if ( Platform.OS === 'ios' ) {
if ( ! this.isFocused() ) {
AztecInputState.focus( this.aztecViewRef.current );
}
this.updateCaretData( event );
}
}
Expand Down

0 comments on commit 3956a0d

Please sign in to comment.