-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add x-trap noinitialfocus modifier #3977
Add x-trap noinitialfocus modifier #3977
Conversation
Adds a new x-trap modifier: .noinitialfocus to trap focus without giving focus to the first element in the focus trap Test included Relates to discussion alpinejs#2806
How does this handle (or communicate to devs) that the focus may now behave unpredictably for assistive technologies? Also, update docs :) |
Thanks for the feedback @ekwoka I'll have to do some testing around how this affects the behaviour of assistive technologies. Will report back and update documentation accordingly |
After testing and consideration of how this feature isn't compatible with assistive technologies, I've come to the conclusion that there are better solutions to the problem I thought it solved (see #2806) Therefore, unless someone wants to argue to the contrary, I'll close this PR |
I like the addition - I've heard of cases where people want to disable autofocus on mobile dialogs because autofocusing automatically pulls up the keyboard when you open a modal and that's not ideal. Anyhow, I like it and changed it to Thanks! |
Apologies for not getting around to writing the documentation @calebporzio I didn't end up closing this because I realised in my use case, which is for a Livewire modal, autofocus has to be implemented by the modal because it has no contents when the page is first loaded. So you end up with an ugly switch in focus. More annoyingly my first field is an address autocompletion, which incurs a fee if activated Anyway, thanks for merging! |
Adds a new x-trap modifier: .noinitialfocus to trap focus without giving focus to the first element in the focus trap
Test included
Relates to discussion #2806
Use case is to be able to create a modal with the option of not focusing the first input. For example, Wire Element Modal is a Livewire component for creating modals, which uses x-trap, and currently has no mechanism (besides tricks like hidden inputs) to create a modal that opens without focusing its first input: wire-elements/modal#367