Skip to content

fix(docs): prevent scroll-to-top on restart/fast buttons in termynal.js#1889

Closed
cesar32az wants to merge 1 commit into
fastapi:masterfrom
cesar32az:fix-termynal-scroll-jump
Closed

fix(docs): prevent scroll-to-top on restart/fast buttons in termynal.js#1889
cesar32az wants to merge 1 commit into
fastapi:masterfrom
cesar32az:fix-termynal-scroll-jump

Conversation

@cesar32az

Copy link
Copy Markdown

Description

Fixes the intermittent scroll-to-top when clicking the "restart" / "fast" controls on the animated terminal blocks in the docs, reported in discussion #1887 (credit to the reporter for the find and the FastAPI-vs-Typer comparison).

Root cause: both controls are anchors with href='#'. Although the click handlers call e.preventDefault(), navigation to # can still slip through (e.g. when restart wipes container.innerHTML mid-event), jumping the page to the top, which matches the "sometimes happens, sometimes doesn't" behavior described in the report.

This is a 1:1 port of the fix already merged and live on the FastAPI docs: fastapi/fastapi#13714, the same two lines in the same vendored termynal.js, using javascript:void(0) so the anchor never navigates.

Verification

  • The diff is identical to the upstream FastAPI fix, in production on fastapi.tiangolo.com since Aug 2025; the reporter confirmed the FastAPI docs behave correctly while the Typer docs do not.
  • docs/js/termynal.js was otherwise already in sync with FastAPI's copy except for these two lines.

Related discussion: #1887

Supersedes #1888 (closed to resubmit with a cleaner commit).

The "restart" and "fast" controls in the animated terminal blocks are
anchors with href='#', so clicking them can navigate to '#' and jump
the page to the top. Use javascript:void(0) instead, matching the fix
already merged in fastapi/fastapi#13714 for the same vendored file.
@github-actions github-actions Bot added the docs Improvements or additions to documentation label Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

📝 Docs preview

Last commit 9d784a9 at: https://8bfd03ab.typertiangolo.pages.dev

Modified Pages

@svlandeg svlandeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please follow the contribution guidelines. A discussion was posted and is awaiting maintainer's decision. Do not open PRs without a maintainer's approval, as this creates too heavy a maintenance burden. Thanks 🙏

@svlandeg svlandeg closed this Jul 7, 2026
@phalberg

phalberg commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Thank you @svlandeg, as this was my discussion.
I am not sure if one should try to force the same user opening up the discussion and making the PR, altough I can see situations where the person making the discussion does not want to make the PR...
It's just that these AI PR's and issues are getting out of hand, might be some other better alternatives to make this process easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants