Skip to content

Commit

Permalink
[RichText]: Ignore selection changes on non contentEditable nodes (#4…
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras authored and adamziel committed Apr 29, 2022
1 parent 8a26638 commit fc2f53f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/rich-text/src/component/use-input-and-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ export function useInputAndSelection( props ) {
onSelectionChange,
} = propsRef.current;

// Check if the implementor disabled editing. `contentEditable`
// does disable input, but not text selection, so we must ignore
// selection changes.
if ( element.contentEditable !== 'true' ) {
return;
}

// If the selection changes where the active element is a parent of
// the rich text instance (writing flow), call `onSelectionChange`
// for the rich text instance that contains the start or end of the
Expand Down

0 comments on commit fc2f53f

Please sign in to comment.