Describe the bug
Mounting cmdk's <Command /> off-screen can trigger Element.scrollIntoView() internally and unexpectedly scroll the page window to that off-screen location.
In our case, this happened even though no hash navigation was used and no explicit app-level scroll logic ran.
Reproduction steps
- Render a long page.
- Place
<Command> in a section far below the fold.
- Navigate to that page from another route while currently at
scrollY = 0.
- Observe that the page jumps down automatically near the
<Command> section.
Expected behavior
The page should stay at top (or keep router/browser restoration behavior), and Command internals should not force-window-scroll when mounted off-screen.
Actual behavior
Window scroll jumps down on mount.
Runtime evidence
When instrumenting Element.prototype.scrollIntoView, the call stack points to cmdk internals:
Element.scrollIntoView
ne (.../cmdk.js:160:152)
.../cmdk.js:451:28
Environment
cmdk: 1.1.1
- React:
19.2.6
- Browser: Chromium (via Cursor embedded browser)
- Router: TanStack Router
Workaround
Delaying/lazy-mounting the off-screen <Command> section avoids the jump, which further suggests the mount-time scrollIntoView path is the trigger.
Describe the bug
Mounting
cmdk's<Command />off-screen can triggerElement.scrollIntoView()internally and unexpectedly scroll the page window to that off-screen location.In our case, this happened even though no hash navigation was used and no explicit app-level scroll logic ran.
Reproduction steps
<Command>in a section far below the fold.scrollY = 0.<Command>section.Expected behavior
The page should stay at top (or keep router/browser restoration behavior), and
Commandinternals should not force-window-scroll when mounted off-screen.Actual behavior
Window scroll jumps down on mount.
Runtime evidence
When instrumenting
Element.prototype.scrollIntoView, the call stack points tocmdkinternals:Element.scrollIntoViewne (.../cmdk.js:160:152).../cmdk.js:451:28Environment
cmdk:1.1.119.2.6Workaround
Delaying/lazy-mounting the off-screen
<Command>section avoids the jump, which further suggests the mount-timescrollIntoViewpath is the trigger.