Skip to content

Fix: back to top button js#618

Open
haotaku wants to merge 7 commits into
mainfrom
fix-back-to-top-button-js
Open

Fix: back to top button js#618
haotaku wants to merge 7 commits into
mainfrom
fix-back-to-top-button-js

Conversation

@haotaku

@haotaku haotaku commented Jan 17, 2025

Copy link
Copy Markdown
Contributor

This PR fixes:

  • The bug where the “Back to Top” button remained visible at all times, despite our documentation stating:

It appears after the user has scrolled down, usually four times the height of the screen’s initially-visible portion.

  • The root cause was that our scroll logic was attached to window.onscroll while the page actually scrolls inside .page-content. Added a scroll event listener on .page-content and updated scrollFunction() to check .page-content.scrollTop.
  • Ensured the button only appears after scrolling.

@haotaku haotaku requested a review from a team as a code owner January 17, 2025 20:43
@haotaku haotaku linked an issue Jan 17, 2025 that may be closed by this pull request
Comment thread docs/js/default.js Outdated
@haotaku haotaku self-assigned this Feb 12, 2025
@haotaku haotaku added the bug Something isn't working label Feb 18, 2025
@haotaku haotaku temporarily deployed to Docs (Sandbox) March 22, 2025 05:52 — with GitHub Actions Inactive
@haotaku haotaku requested a review from james-alt March 22, 2025 05:54
@isralduke

Copy link
Copy Markdown
Contributor

womm

@frogpad7 frogpad7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a way to write this a bit more cleanly; otherwise it functions as intended.

Comment thread docs/js/default.js Outdated
@haotaku haotaku requested a review from a team as a code owner August 7, 2025 01:22
@haotaku haotaku temporarily deployed to Docs (Sandbox) August 7, 2025 01:22 — with GitHub Actions Inactive
@haotaku haotaku requested a review from a team as a code owner August 7, 2025 01:37
@haotaku haotaku temporarily deployed to Docs (Sandbox) August 7, 2025 01:38 — with GitHub Actions Inactive
@haotaku haotaku temporarily deployed to Docs (Sandbox) August 7, 2025 01:38 — with GitHub Actions Inactive
@haotaku haotaku requested a review from frogpad7 August 7, 2025 01:40
Comment thread package.json
Comment thread package-lock.json
Comment thread docs/whats-new/index.md Outdated
haotaku and others added 5 commits January 22, 2026 09:31
- fixed triple-backtick (``` ``` ) markers from previous commit with proper js block comment syntax
After testing, I realized removing window.onscroll broke the button on pages without .page-content. Fixed by:

- Reintroducing window.onscroll as a fallback.
- Hiding the button on load to prevent flashing.
- Showing the button only after scrolling down.
@haotaku haotaku force-pushed the fix-back-to-top-button-js branch 2 times, most recently from cb36323 to d2ee8b8 Compare January 22, 2026 16:12
@haotaku haotaku requested review from a team January 22, 2026 17:42
rltucker
rltucker previously approved these changes Jan 22, 2026

@rltucker rltucker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as intended

@isralduke

Copy link
Copy Markdown
Contributor

lgtm

@haotaku haotaku added help wanted Extra attention is needed ready for review Ready for Review javascript Pull requests that update Javascript code documentation Improvements or additions to documentation labels Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation help wanted Extra attention is needed javascript Pull requests that update Javascript code ready for review Ready for Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Back to Top Button JS

5 participants