cmdk icon indicating copy to clipboard operation
cmdk copied to clipboard

Prevent scrollIntoView when component is mounted

Open genius257 opened this issue 1 year ago • 2 comments

Currently when component is mounted it triggers the first item to be selected by default, followed by that item being scrolled into view. I would like an option to disable the scroll, when no user interaction has occurred, yet.

This issue could be solved via #171, but a ideal solution would be a way to just disable the scroll on mount, and not being forced to have nothing as the selection.

genius257 avatar Oct 21 '24 14:10 genius257

https://github.com/pacocoursey/cmdk/blob/9827edf89fc663e24188f9d715a0dca01a736d6d/cmdk/src/index.tsx#L230-L232

this is the code triggering the scroll

andrewdoro avatar Jan 23 '25 15:01 andrewdoro

This scroll might also be problematic when zoom >100% Example here:

  • zoom in
  • open command
  • view is scroll unexpectedly
  • depending on the level of zoom, the offset is more or less problematic

https://github.com/user-attachments/assets/38aa3f63-29e0-4547-ac72-e1d0c386108f

brian-xu-vlt avatar Jul 05 '25 18:07 brian-xu-vlt