Skip to content

Fix back-to-top button not appearing at page bottom in Firefox - #15313

Closed
cderv wants to merge 2 commits into
quarto-dev:mainfrom
cderv:fix/back-to-top-bottom-detection
Closed

cderv wants to merge 2 commits into
quarto-dev:mainfrom
cderv:fix/back-to-top-bottom-detection

Conversation

@cderv

@cderv cderv commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

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) required window.innerHeight + currentScrollTop to reach document.body.offsetHeight exactly. 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 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): 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 - 1 instead: the scrollable document height, with a 1px tolerance for sub-pixel scroll positions.

Test Plan

  • tests/integration/playwright/tests/book-back-to-top.spec.ts passes locally on chromium, firefox and webkit
  • The firefox project of book-back-to-top.spec.ts passes on CI (Linux and macOS)

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Posit Assistant (Codebot)
  • Codebase grounding: local clone
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

cderv added 2 commits November 6, 2026 17:01
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.
@posit-snyk-bot

posit-snyk-bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv

cderv commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Superseded by #15314, opened from an upstream branch instead of the fork.

@cderv cderv closed this Nov 6, 2026
@cderv
cderv deleted the fix/back-to-top-bottom-detection branch November 6, 2026 16:27
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.

2 participants