Skip to content

fix: HTML tooltip misplaced by exactly the scroll delta… (#1163) - #1178

Open
JazibAli360 wants to merge 1 commit into
ecomfe:masterfrom
JazibAli360:donate/1163-html-tooltip-misplaced-by-exactly-the-sc
Open

JazibAli360 wants to merge 1 commit into
ecomfe:masterfrom
JazibAli360:donate/1163-html-tooltip-misplaced-by-exactly-the-sc

Conversation

@JazibAli360

Copy link
Copy Markdown

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 --silent passes
  • npm run lint --silent passes
  • npm run lint --silent passes
  • added/updated test: test/ut/spec/core/dom.test.ts::dom transformCoordWithViewport inverse should not be stale after forward refreshes

Notes 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.

@muchinski

Copy link
Copy Markdown

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

No deployments
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.

HTML tooltip misplaced by exactly the scroll delta: forward/inverse pointer transformers share one srcCoords cache key

2 participants