Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RichText]: Ignore selection changes on non contentEditable nodes #40611

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[RichText]: Ignore selection changes on non contentEditable nodes
  • Loading branch information
ntsekouras committed Apr 26, 2022
commit d6717c4799e30b297b0b0d8a2dc8c759681c4e99
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