Repository navigation
fix(edit): selection changes are followed again after a re-attach - #2
Merged
Merged
Conversation
RichInput.detach cancelled the pending animation frame but kept its handle, so every later selection change returned early. The editor then stopped knowing where the caret was: the page holding the caret was no longer kept mounted while scrolling, and text typed after scrolling away landed at the top of the document instead of at the caret. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Member
|
Hi @abe238, thank you for reporting this bug so early. I did get your email and have not had the chance to reply yet, so thank you all the more for opening this PR. This morning, right after your first email, I quickly pushed a fix in 0.13.1, but it looks like that still did not solve it. I am really glad you found the cause and fixed it. |
pierreneter
approved these changes
Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happens
After the editor re-attaches its input (for example when the document view is re-mounted), typing stops following the caret. If you click in a paragraph, scroll away and type, the text lands at the top of the document instead of where the caret was.
Cause
RichInput.detachcancels the pending animation frame but keeps its handle inthis.raf.onSelChangereturns early whilethis.rafis set, so after a detach and attach every later selection change is ignored. The editor no longer knows where the caret is, and the page that holds the caret is not kept mounted while scrolling.Fix
One line: reset
this.rafto0indetach.Test
test/input-reattach.test.tsattaches, changes the selection, detaches, attaches again, and checks that a selection change is still followed. It fails onmainwithout the change and passes with it.Checked on current
main(v0.13.0):bun test test/passes (497 tests),bun run typecheckpasses. I did not run the e2e suite.Found while building on office-engine. Thank you for the project.