Skip to content

fix: restore scroll position when RTL component preview mounts#10434

Open
arifwp wants to merge 1 commit intoshadcn-ui:mainfrom
arifwp:fix/command-page-auto-scroll
Open

fix: restore scroll position when RTL component preview mounts#10434
arifwp wants to merge 1 commit intoshadcn-ui:mainfrom
arifwp:fix/command-page-auto-scroll

Conversation

@arifwp
Copy link
Copy Markdown

@arifwp arifwp commented Apr 18, 2026

What does this PR do?

Fixes the auto-scroll behavior on the Command component docs page when navigating to:

  • /docs/components/radix/command
  • /docs/components/base/command

Root Cause

The RTL ComponentPreview renders a LanguageSelector which uses Base UI's Select component. Base UI Select internally renders a hidden input that receives focus on mount, causing the browser to scroll to its position (~4435px down the page).

Fix

Capture window.scrollY before the RTL component mounts, then restore it after mount via requestAnimationFrame.

How to test

  1. Navigate to /docs/components/radix/command
  2. Page should no longer auto-scroll to bottom on load

Closes #10394

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 18, 2026

@arifwp is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

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.

[bug]: Docs: The URLs "docs/components/(radix|base)/command" automatically scroll to the bottom.

1 participant