Skip to content

Commit

Permalink
Merge pull request #86 from wordpress-mobile/fix/loop-deleting-fast-i…
Browse files Browse the repository at this point in the history
…nsert-fast

Fix `onFocus` called too many times
  • Loading branch information
daniloercoli authored Dec 4, 2018
2 parents 1e0ed52 + 605962f commit daf2d1c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/AztecView.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ class AztecView extends React.Component {
}

_onPress = () => {
this.focus();
this.focus(); // Call to move the focus in RN way (TextInputState)
this._onFocus(); // Check if there are listeners set on the focus event
}

render() {
Expand All @@ -138,7 +139,10 @@ class AztecView extends React.Component {
onHTMLContentWithCursor = { this._onHTMLContentWithCursor }
onSelectionChange = { this._onSelectionChange }
onEnter = { this._onEnter }
onFocus = { this._onFocus }
// IMPORTANT: the onFocus events are thrown away 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
onFocus = { () => {} }
onBlur = { this._onBlur }
onBackspace = { this._onBackspace }
/>
Expand Down

0 comments on commit daf2d1c

Please sign in to comment.