[Repo Assist] Use Popover API for code snippet tooltips; fix scroll-offset positioning#1061
Conversation
- Add `popover` attribute to `div.fsdocs-tip` elements in HtmlFormatting.fs,
placing them in the browser top layer when supported (Baseline 2024).
- Update fsdocs-tips.js to call showPopover()/hidePopover() on browsers that
support the Popover API; fall back to display:block/none on older browsers.
- Switch to `position: fixed` in the Popover API path (correct for top-layer
elements) and fix a scroll-offset bug where tooltips appeared at wrong
positions when the page was scrolled.
- Fix a minor bug in the right-edge overflow correction (was using `y` instead
of `x` as the base for the left-shift calculation).
- Add `div.fsdocs-tip:popover-open { display: block }` to fsdocs-default.css
so author-level display:none does not suppress the Popover API reveal.
- Update RELEASE_NOTES.md.
Closes #422
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-613ba4f90485b3ec
…fade-in - CSS: add `inset: unset` to `div.fsdocs-tip:popover-open` to reset the UA popover stylesheet's `inset: 0` (i.e. right:0 / bottom:0), which was stretching the element across the viewport and causing the visible dark area around the tooltip. - CSS: add `position: fixed` explicitly in the :popover-open rule so the element is correctly anchored to the JS-supplied left/top coordinates. - CSS: add a 120ms ease-out opacity fade-in animation for a subtle reveal. - JS: remove the display-toggle fallback branch entirely. The Popover API is Baseline 2024 (Chrome 114+, Firefox 125+, Safari 17+) and the technical audience of fsdocs users will have modern browsers. - RELEASE_NOTES: update entry to reflect the simplified (no-fallback) design and the animation addition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
|
/repo-assist the black background is not fixed for me in latest Chrome. I also wonder if we still need the more archaic code generated in onmouseout and onmouseover to trigger popover feels like fighting the modern api. |
…ion; fix Chrome popover background - HtmlFormatting.fs: emit data-fsdocs-tip / data-fsdocs-tip-unique instead of inline onmouseover/onmouseout handlers; overlapping vs non-overlapping cases now produce identical output (owner param is no longer needed) - GenerateHtml.fs (ApiDocs): same data-* attrs on code elements; add the popover attribute to fsdocs-tip divs so showPopover() works there too - fsdocs-tips.js: add delegated mouseover/mouseout listeners that read data-fsdocs-tip attributes; wrap showPopover() in try/catch for safety; keep showTip/hideTip on window for backward-compat with cached docs - fsdocs-default.css: add explicit background-color inside :popover-open to override Chrome UA top-layer canvas default (fixes black background); add [data-fsdocs-tip] cursor rule alongside legacy span[onmouseout] Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
|
🤖 Repo Assist here — I've just pushed a follow-up commit addressing both points. What changedBlack background in Chrome (
|

🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #422
Summary
Migrates hover tooltips (the
div.fsdocs-tipelements shown when hovering over syntax tokens in code blocks) to use the browser-native [Popover API]((developer.mozilla.org/redacted), with a clean fallback for older browsers.Changes
src/FSharp.Formatting.CodeFormat/HtmlFormatting.fsAdd the
popoverattribute to every generateddiv.fsdocs-tipelement:docs/content/fsdocs-tips.jsposition: fixed, then callel.showPopover()/el.hidePopover(). Elements in the top layer are always rendered above all other page content — noz-indexarithmetic needed.position: absolute+display: block/nonebehaviour unchanged.yinstead ofxas the base for the left-shift; corrected tox.currentTipElementwas never cleared on hide; now set tonulltogether withcurrentTip.docs/content/fsdocs-default.cssAdd
div.fsdocs-tip:popover-open { display: block; }so the author-leveldisplay: nonerule does not suppress the Popover API reveal (author rules take precedence over UA rules in the cascade). Also addmargin: 0to prevent UA default popover margins from shifting the tooltip.Why the Popover API?
z-index: 1000clientX/Yused withposition: absolute→ offset when scrolledclientX/Yused withposition: fixedin top layerdocument.onkeydownhandlerautopopoversTest Status
dotnet build src/FSharp.Formatting.CodeFormat/— 0 warnings, 0 errorsdotnet test tests/FSharp.CodeFormat.Tests/— 20 passed, 2 skipped (pre-existing infrastructure skips).fsfile — no changes needed