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

fix: supplement of (fix: Prevent ReactEditor.toDOMRange crash in setDomSelection #5741) #5792

Merged
merged 6 commits into from
Jan 27, 2025
Merged
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion packages/slate-dom/src/plugin/with-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ export const withDOM = <T extends BaseEditor>(
case 'remove_node':
case 'merge_node':
case 'move_node':
case 'split_node': {
case 'split_node':
case 'insert_text':
case 'remove_text':
case 'set_selection': {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think set_selection should be in this list no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For same reason mentioned:
onDOMSelectionChange should not be executed before any selection-changing operations are synchronized to the DOM.

Because onDOMSelectionChange( throttle) may be executed at any time(May be just right after editor.selection change and before editor.selection sync to domSelection)

set_selection op also changes editor.selection like others

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay got it sorry 👍 In that case I would suggest to rename the IS_NODE_MAP_DIRTY to something closer to it's real implications, like IS_DOM_EDITOR_DESYNCED for example. My 2cts though, and could be done in another PR.

I faced the issue too, and I think your change could fix it 🙏

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with landing this and renaming it in another PR. I'll add a FIXME.

IS_NODE_MAP_DIRTY.set(e, true)
dylans marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down
Loading