Skip to content

🐛 Prevent scroll-to-top on restart/fast buttons in the documentation#1904

Merged
tiangolo merged 1 commit into
fastapi:masterfrom
phalberg:master
Jul 22, 2026
Merged

🐛 Prevent scroll-to-top on restart/fast buttons in the documentation#1904
tiangolo merged 1 commit into
fastapi:masterfrom
phalberg:master

Conversation

@phalberg

Copy link
Copy Markdown
Contributor

Pull Request

Discussion: #1887

Description

Motivation

Upon clicking fast or restart in terminal widgets within the documentation, one would be forced to the top-of-the-page, which disrupts the user and makes it slightly harder to read documentation (perhaps).

Solution

This was a previously resolved issue in the FastAPI docs and the fix was proposed in this PR: fastapi/fastapi#13714 - which eventually got merged.

I used the same fix that was merged there, changing href = # to rather be href = javascript:void(0), which should keep consistency across the repos.

(I suggest looking at the original FastAPI PR for more technical depth on the solution, which I linked above)

AI Disclaimer

No AI was used in the process of this PR.

Checklist

  • This PR links to a GitHub Discussion for the proposed code change.
  • I added tests for the change.
  • The new or updated tests fail on the main branch and pass on this PR.
  • Coverage stays at 100%.
  • The documentation explains the change if needed.

@github-actions github-actions Bot added the docs Improvements or additions to documentation label Jul 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📝 Docs preview

Last commit 3222610 at: https://7c266ce6.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.

I haven't reviewed/checked this in detail, but I know that @YuriiMotov did for fastapi/fastapi#13714 so this is more than likely just fine.

I can confirm that I've encountered this bug earlier in the Typer docs myself. The "being forced to the top" actually didn't always happen for me, but sometimes.

Either way, on the documentation pages produced with this PR, I can't replicate the bug anymore 🎉

Thanks @phalberg !

@svlandeg
svlandeg marked this pull request as ready for review July 22, 2026 10:23

@tiangolo tiangolo 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.

Nice, thank you! 🚀

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.

3 participants