cmdk icon indicating copy to clipboard operation
cmdk copied to clipboard

Disable autofocus on mobile devices

Open rajbirjohar opened this issue 2 years ago • 8 comments

When the menu is open on mobile devices, the <Command.Input /> element grabs focus automatically which is expected.

Now the issue is that the mobile keyboard also pops up and covers most of the items. Is there a way to disable the auto focus on mobile devices? I've already tried a number of possible solutions such as preventDefault(), setting autoFocus={false}, setting tabIndex="-1", creating a second "hidden" input (which also grabbed focus) and nothing worked. It's kind of a pain to open the menu and then have to collapse the keyboard every time I want to scroll down.

Am I missing something or is it explained in the documentation somewhere?

rajbirjohar avatar May 01 '23 14:05 rajbirjohar

Yeah this is annoying, what you want is to change the onOpenAutoFocus event from Radix's Dialog.Content component, but we currently don't support passing props through to that element.

pacocoursey avatar May 01 '23 16:05 pacocoursey

That makes sense @pacocoursey. Would we be expecting this to come out in a future release? Or would it be a difficult feature to implement? I can try taking a look.

rajbirjohar avatar May 01 '23 16:05 rajbirjohar

is there an update or workaround for this?

eternity4318 avatar Jan 30 '24 19:01 eternity4318

#213 https://github.com/pacocoursey/cmdk/pull/213

eternity4318 avatar Jan 31 '24 02:01 eternity4318

Are there any plans to fix this? and are there any temporary workarounds for this?

ImJustChew avatar Jul 30 '24 07:07 ImJustChew