fix: derive selection geometry from effective scale#1094
Open
jedrazb wants to merge 2 commits into
Open
Conversation
…1083, fixes #1075) Two separate causes in one class — mixing post-transform values (getBoundingClientRect, clientX) with pre-transform ones (offsetWidth, style.top, the layout model). #1083: geometry converted screen deltas to layout px by dividing by the editor's own zoom state. A consumer scaling an ancestor renders the pages at zoom * externalScale while zoom still reads 1, so the caret landed hundreds of px off. The scale is now measured off the DOM (getBoundingClientRect().width / offsetWidth) via getEffectiveScale, so a scale the editor does not own resolves without the consumer configuring anything. With no external scale the measurement equals zoom exactly, so existing behavior is unchanged. #1075: independent of the above and present at the editor's own zoom. The composer's fixedY is measured as a client-rect delta, and resolveItemPositions multiplied it by zoom a second time, placing it (1 - zoom) * fixedY from its selection. The implementation now matches the contract its own docstring states. anchorKey values are pagination coords and keep their scaling; Vue passes zoom 1 here, so it is a no-op there. Vue's fix is not a copy of React's: its pages carry the scale themselves while the overlay is their unscaled parent, so the two frames need different factors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Vue IME candidate window: build the anchor from the raw screen delta plus the overlay's screen origin, not overlay-local px added to a screen origin, which landed the candidate window ~a third short under external scale. - Drop the unreachable `|| zoom` fallbacks in readScale / pagesScale / toOverlayLocal; getEffectiveScale is always positive-finite. The React hook no longer takes a zoom prop it never used. On an unmeasurable container the scale is 1, and the comments now say so. - Soften the changeset to "Fixes #1075; partially addresses #1083" — the diff covers caret/selection/composer geometry under scale, not page-detection or scroll-container sizing. - Strengthen two tests: the resolveItemPositions collision test now asserts the pushed-down anchor-card position, and the effective-scale e2e imports and calls the shipped getEffectiveScale instead of re-deriving the formula. - Add a Vue e2e assertion on the IME anchor (coordsAtPos lands on the painted caret) under external scale. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
All contributors have signed the CLA ✍️ ✅ Posted by the CLA bot. |
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.
The new-comment composer was misplaced at any zoom other than 100% because a page-relative position was scaled twice, and caret/selection geometry ignored a CSS scale applied by a wrapping container. Selection and composer geometry now derive the effective scale from the rendered DOM, so caret, selection rects, and the composer land correctly under both the editor's own zoom and an external scale.
Fixes #1075
Partially addresses #1083 (caret, selection, and composer geometry under an external scale); page-detection and scroll-container sizing under external scale remain open.
🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.