Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for middle/cmd clicking an item to open in new tab #156

Open
tarngerine opened this issue Jul 10, 2023 · 3 comments
Open

Support for middle/cmd clicking an item to open in new tab #156

tarngerine opened this issue Jul 10, 2023 · 3 comments

Comments

@tarngerine
Copy link

we have some items that are links, whats the recommended approach to support middle clicking? i could imagine onSelect handler passing the event

@tarngerine tarngerine changed the title Support for middle clicking an item to open in new tab Support for middle/cmd clicking an item to open in new tab Jul 10, 2023
@joaom00
Copy link
Contributor

joaom00 commented Jul 10, 2023

You can use an anchor tag inside Command.Item

https://codesandbox.io/s/silly-solomon-mthm2w?file=/src/App.tsx

@tarngerine
Copy link
Author

@joaom00 thanks for chiming in, but this doesnt support the standard onSelect keyboard behavior (navigate on return)

best way i'm hacking it is to add an anchor tag inside, but also keep onSelect on the CommandItem. however, the anchor tag needs to have its own click handler that e.stopPropagation to prevent double firing (in the case where you have side effects from onSelect, which I do)

@joaom00
Copy link
Contributor

joaom00 commented Jul 16, 2023

Ohh I see, yeah I think your approach is the way to go for now. I guess if #138 gets merged you will be able to have the desired behavior. Would be like this:

<Command.Item asChild>
  <a />
</Command.Item>

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants