Repository navigation
fix(226629): tooltips after SPA/Turbo navigation + hotspot no longer shifts its element (226620) - #196
Merged
Conversation
… shifts its element (226620) #226629: hotspot tooltips only appeared after a full reload. - The MutationObserver watched document.body; Turbo Drive swaps in a new <body> on every visit, so new pages were never seen. Observe document.documentElement instead. - On a URL change only the nodes added in that same batch were checked, so a target rendered before the URL flipped was missed. Re-run the page rules and scan the page on every URL change (also polled every second), and remove tooltips whose page rules no longer match. - Elements that still carried our marker (Turbo page snapshot, or a re-render that wiped the hotspot) were skipped forever. Re-link them; drop dead popup copies from restored snapshots. - destroy() (run on every session change) stopped the observer for good. load() restarts it; no rAF wait needed for documentElement. #226620: the hotspot anchor was inserted as the element's first child as a floated inline-block, so flex/grid gaps, sibling margins (space-x) and :first-child styles pushed the element's content right. The anchor is now an absolutely positioned 0x0 box appended last, and the hotspot sits at the content's right edge (our anchor excluded from the measurement), so it no longer overlaps the text. Also: an explicit Offset X of 0 was replaced by the 4px default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes two Hubflo tooltip tickets (#226629, #226620). Hubflo loads
sdk.gleap.io/latestand runs on Turbo Drive.#226629: hotspot only showed after a full reload
Root causes in
src/GleapTooltipManager.js:<body>.observe(document.body): Turbo Drive swaps in a new<body>on every visit, so the observer kept watching the detached one and never saw the new page. It now observesdocument.documentElement.checkForTooltips), and removes tooltips whose rules no longer match. The URL is also polled every second, as the other managers do.data-gleap-tooltipmarker blocked re-linking. Turbo restores cached page snapshots, which still carry our marker and a dead anchor. A re-render that sets the element's text (ReacttextContent) also wipes the hotspot.linkTooltipreturned early in both cases. It now re-links unless the element has a working link, and it drops dead popup copies that come back with a restored snapshot.destroy()stopped the observer for good.destroy()runs on every session change, and nothing restarted the observer.load()now callsstart()again (it is idempotent). The observer is created directly, without waiting onrequestAnimationFrame.autoUpdate. Hover listeners are removed on cleanup.#226620: a gap ("tab space") was added before the heading text
The anchor was inserted as the element's first child as a floated
inline-block. In a flex/grid heading it became a flex item, sogapwas applied. It also made the real first child a sibling, sospace-x/* + *margins applied, and it broke:first-childstyles. The anchor is now a 0×0position:absolutebox (inline!important), appended as the last child, so the host's layout is untouched.The hotspot used to be placed at
range(selectNodeContents).width + paddingLeft. That measurement included our own anchor and hotspot, which is why the icon sat on top of "permissions" in the customer's first screenshot. It now uses the content's right edge, measured up to our anchor.Also: an explicit Offset X of
0was replaced by the 4px default (!tooltip.offsetX). 0 is now honored. The dashboard editor and the server both default to 0.Verification
Built the SDK, then loaded the old (master) and new bundles in a static page with a mocked Gleap API:
space-xfirst child shift 24px → 0, hotspot vs. text end −12px (overlapping) → 0 with Offset X 0. Hover popup still shows.<body>swap → linked within 200 ms; restored snapshot clone → re-linked with 1 anchor and no stale popups;textContentre-render → hotspot back; target rendered beforepushStatewith no later mutation → linked; navigating to a non-matching URL → tooltip removed; a late render on a matching page → linked.npx jest: 34 suites / 586 tests pass.No release in this PR. It ships with the next JS SDK release (
/latestCDN).🤖 Generated with Claude Code