Skip to content

🐛 Prevent scroll-to-top on restart/fast buttons in termynal.js#1888

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

🐛 Prevent scroll-to-top on restart/fast buttons in termynal.js#1888
cesar32az wants to merge 1 commit into
fastapi:masterfrom
cesar32az:fix/termynal-scroll-to-top

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 today 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

  • Diff is identical to the upstream FastAPI fix, which has been in production on fastapi.tiangolo.com since Aug 2025 — the reporter themselves confirmed the FastAPI docs behave correctly while the Typer docs don't.
  • docs/js/termynal.js was otherwise already in sync with FastAPI's copy except for these two lines (and one blank line).

Related discussion: #1887

Port of fastapi/fastapi#13714: the `restart ↻` and `fast →` controls
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 live on the FastAPI docs.

Claude-Session: https://claude.ai/code/session_01HJ8JfXbXGXcAk2jEh2dZVg
@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 2fbe5bb at: https://e665272d.typertiangolo.pages.dev

Modified Pages

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.

2 participants