Repository navigation
fix: HTML tooltip misplaced by exactly the scroll delta… (#1163) - #1178
Open
JazibAli360 wants to merge 1 commit into
Open
JazibAli360 wants to merge 1 commit into
JazibAli360 wants to merge 1 commit into
Conversation
|
We hit this in production on touch devices: a tooltip appended to the body inside a scrolling container was placed at the chart's pre-scroll position, about 2,600 px off-screen on iOS. This change fixes the root cause (we work around it by clearing srcCoords before each touch). |
This branch has not been deployed
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.
preparePointerTransformer in src/core/dom.ts now keeps a separate cache-validity key (invSrcCoords) for the inverse transformer, so the forward and inverse transformers are each checked against the marker rects they were built from. Added a jsdom unit test that reproduces the stale inverse transform after a scroll.
Fixes #1163 (#1163)
What changed
preparePointerTransformer in src/core/dom.ts now keeps a separate cache-validity key (invSrcCoords) for the inverse transformer, so the forward and inverse transformers are each checked against the marker rects they were built from. Added a jsdom unit test that reproduces the stale inverse transform after a scroll.
Root cause: The forward ('trans') and inverse ('invTrans') transformers shared one saved.srcCoords key. A forward call made after a scroll refreshed that key, so the next inverse call saw matching coords and kept returning the inverse transformer built at mount time. Results were off by the scroll delta.
How it was verified
npm test --silentpassesnpm run lint --silentpassesnpm run lint --silentpassestest/ut/spec/core/dom.test.ts::dom transformCoordWithViewport inverse should not be stale after forward refreshesNotes for reviewers
The new test fails before the fix (off by exactly the 50px scroll delta) and passes after it. All 69 tests pass and lint is clean. The change is three lines and matches the fix the issue suggests. Caching works the same as before when nothing moves. The test fakes layout (offsetLeft/offsetTop/getBoundingClientRect) because jsdom has no layout engine, and it restores those fakes afterwards. A maintainer may prefer a different test style.
🤖 Generated with Claude Code by the token-tithe engine, an AI contribution donated from
leftover agent tokens. Model: claude-opus-5-5 · tokens: 227,266 (~$0.27) · second
review: none available. Happy to change anything, or to close this if it isn't a fit. To opt
this repository out of all future donations, add a file named
.github/token-tithe-ignore.