fix: move the context popup onto its selection when the selection changes - #174
Merged
Merged
Conversation
Radix registers a virtual anchor once per object identity, so the single anchor the popup held could never be re-measured: nothing short of a scroll or a resize moved it. A fresh identity per request is what asks floating-ui to measure again, and it lets the anchor read the request it was built for rather than a ref that existed to keep one object current.
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.
Summary
An open context popup stayed where it opened while the selection it acts on moved, so it ended up pointing at text the selection had left behind. Scrolling moved it correctly, which is what made the gap easy to miss.
docs/specification.md— the popup follows its selection, not only the scroll.Related Issue
Closes #171
Verification
Added to
EditorContextPopup.test.tsx: a fresh request that measures the selection somewhere else moves the popup by exactly that distance. The existing pin test now moves the selection under a focused popup and asserts the position does not change, which is the second criterion on the issue.Manually verified in the desktop app on Windows:
Shift+Downkeeps the popup against the selection instead of leaving it behind.Shift+F10, holding focus, stays where it was pinned while the selection changes.Notes
PopoverAnchor, not the anchor carried on the request. Corrected in a comment there.Shift+Arrow. Easing that motion is Ease the context popup's movement when it repositions #172, which this unblocks.