Skip to content

Commit

Permalink
RichText: ignore selection changes during composition (#16960)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored and youknowriad committed Aug 14, 2019
1 parent ae7b8bc commit 2b3a2d4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,11 @@ class RichText extends Component {
}

/**
* Handles the `selectionchange` event: sync the selection to local state.
* Syncs the selection to local state. A callback for the `selectionchange`
* native events, `keyup`, `mouseup` and `touchend` synthetic events, and
* animation frames after the `focus` event.
*
* @param {Event} event `selectionchange` event.
* @param {Event|SyntheticEvent|DOMHighResTimeStamp} event
*/
onSelectionChange( event ) {
if (
Expand All @@ -403,6 +405,15 @@ class RichText extends Component {
return;
}

// In case of a keyboard event, ignore selection changes during
// composition.
if (
event.nativeEvent &&
event.nativeEvent.isComposing
) {
return;
}

const { start, end } = this.createRecord();
const value = this.getRecord();

Expand Down

0 comments on commit 2b3a2d4

Please sign in to comment.