don't auto focus first element on x-trap #2806
Replies: 5 comments 5 replies
-
It's not possible at the moment but the plugin uses "focus trap" which does support it. If you have a valid use case, you can try to submit a PR. |
Beta Was this translation helpful? Give feedback.
-
I'm having the same issue. I don't so much mind the first element being auto-focused, but when (in my case) I use it with Tailwind's |
Beta Was this translation helpful? Give feedback.
-
PR #3977 |
Beta Was this translation helpful? Give feedback.
-
There is kind of an issue, in that without this focus, the next tab may go into the browser UI and not the website at all, or somewhere else entirely if you aren't using inert. |
Beta Was this translation helpful? Give feedback.
-
In my testing (chrome), the tabbing behaves as I'd expect it to. After the focus trap, the first (keyboard) tab sets focus to the first tabbable element in the trap container It does, however, break the flow of focus in terms of accessibility. For example, used to create a modal, if the modal is opened by clicking a button, focus doesn't transition from the button to an element inside the modal - at least not in a way that something like a screen reader can follow. Focus is trapped inside the modal, but a click or tab is necessary to see this For my use case, in which I don't want the first input in my modal to automatically receive focus, I've decided a better solution is to use |
Beta Was this translation helpful? Give feedback.
-
Is there a way to stop the auto focus of the first element when using x-trap?
Beta Was this translation helpful? Give feedback.
All reactions