tailwindlabs / headlessui

Completely unstyled, fully accessible UI components, designed to integrate beautifully with Tailwind CSS.
https://headlessui.com
MIT License
25.81k stars 1.07k forks source link

Trying to remove focus from Switch component #3440

Open barbararcbf12 opened 1 month ago

barbararcbf12 commented 1 month ago

What package within Headless UI are you using? @headlessui/react

What version of that package are you using? ^2.1.2

What browser are you using? Chrome

Reproduction URL

Describe your issue I have a menu that is closed (hidden) at first, and it opens if clicked or the "Enter" key is pressed. I am in a situation where I have a Switch component located in the menu I mentioned above. So, I would like to remove the focus from the Switch element when the menu is closed, but I am stumbling upon the fact that I cannot assign "-1" to the tabIndex prop. Would it be possible to change it so I can disable focus to the Switch component?

https://github.com/tailwindlabs/headlessui/blob/49c081d199a315d924b31c2ecec49196c10f7206/packages/%40headlessui-react/src/components/switch/switch.tsx#L227