Skip to content

Commit f76f679

Browse files
ellatrixclaude
andcommitted
Don't sync the selection from a rich text edited inside another host
When a rich text is itself focused but nested inside another editing host (e.g. an HTML block's static inner blocks), writing flow owns its selection. Return early from the selection change handler in that case, matching the focus handler, so the permanently subscribed listener does not fight writing flow over the caret. The editable root host case is unaffected: there the host holds focus, not the element. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c6cc10b commit f76f679

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

packages/rich-text/src/hook/event-listeners/input-and-selection.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,17 @@ export default ( props ) => ( element ) => {
142142
return;
143143
}
144144

145+
// When this element is itself focused but nested inside another
146+
// editing host (e.g. an HTML block's static inner blocks), writing
147+
// flow owns its selection; don't self-sync. The editable root host
148+
// case is different: the host holds focus, not this element.
149+
if (
150+
ownerDocument.activeElement === element &&
151+
element.parentElement.closest( '[contenteditable="true"]' )
152+
) {
153+
return;
154+
}
155+
145156
// In case of a keyboard event, ignore selection changes during
146157
// composition.
147158
if ( isComposing ) {

0 commit comments

Comments
 (0)