Skip to content

Guard collapseToEnd when the live DOM selection has no ranges - #6099

Merged
dylans merged 1 commit into
ianstormtaylor:mainfrom
BetterAndBetterII:cursor/guard-collapsetoend-rangecount-0051
Aug 25, 2026
Merged

Guard collapseToEnd when the live DOM selection has no ranges#6099
dylans merged 1 commit into
ianstormtaylor:mainfrom
BetterAndBetterII:cursor/guard-collapsetoend-rangecount-0051

Conversation

@BetterAndBetterII

Copy link
Copy Markdown
Contributor

While composing, Editable's selection-sync layout effect called collapseToEnd() even when the live DOM Selection had rangeCount === 0. That throws InvalidStateError during React commit and unmounts the editor.

Skip collapseToEnd() when there is no range. The setBaseAndExtent / removeAllRanges path is unchanged.

Fixes #6097

Selection.collapseToEnd() throws InvalidStateError when rangeCount is 0.
Skip that call during composition selection-sync so a cleared DOM
selection cannot unmount the editor from a layout-effect throw.

Co-authored-by: Yuzhong Zhang <BetterAndBetterII@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b68a1d6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
slate-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dylans
dylans merged commit ad04f91 into ianstormtaylor:main Aug 25, 2026
11 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidStateError: unguarded domSelection.collapseToEnd() in Editable's selection sync (rangeCount === 0)

3 participants