Repository navigation
Fix back-to-top button not appearing at page bottom in Firefox - #15314
Merged
Merged
Conversation
The bottom-of-page check in the scroll handler required window.innerHeight + currentScrollTop to reach document.body.offsetHeight exactly. Browsers report sub-pixel scroll positions, so at the bottom of a page whose height is fractional the sum can land a fraction of a pixel below the integer offsetHeight, and the check never passes. This stayed latent until CI moved from Playwright 1.64.1 (Firefox 157) to 1.65.0 (Firefox 159), which shifted the scroll metrics of the book playwright fixture enough to fail the check deterministically on Linux and macOS. Compare against document.documentElement.scrollHeight - 1 instead: the scrollable document height, with a 1px tolerance for sub-pixel scroll positions.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
2 of 7 tasks
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.
Description
When a reader scrolls to the bottom of a website or book page in Firefox, the back-to-top button does not appear. It appears in Chromium and WebKit on the same page.
Root Cause
The bottom-of-page check in the scroll handler (
src/resources/projects/website/navigation/quarto-nav.js:77) requiredwindow.innerHeight + currentScrollTopto reachdocument.body.offsetHeightexactly. Browsers report sub-pixel scroll positions, so at the bottom of a page with a fractional document height the sum can land a fraction of a pixel short of the integeroffsetHeight, and the check never passes.This stayed latent until CI moved from Playwright 1.64.1 (Firefox 157) to 1.65.0 (Firefox 159): the book back-to-top playwright test added in #14889 started failing deterministically on Linux and macOS, and the CI trace shows the page fully scrolled with the button still hidden.
Fix
Compare against
document.documentElement.scrollHeight - 1instead: the scrollable document height, with a 1px tolerance for sub-pixel scroll positions.Test Plan
tests/integration/playwright/tests/book-back-to-top.spec.tspasses locally on chromium, firefox and webkitbook-back-to-top.spec.tspasses on CI (Linux and macOS)Checklist
I have (if applicable):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.