Skip to content
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

Adds autofocus awareness to the focus plugin #2946

Merged
merged 1 commit into from
Jun 7, 2022

Conversation

aidan-casey
Copy link
Contributor

Currently, when using x-trap, the first child element in the tab order is focused per the focus-trap package defaults. This pull request adds a more sensible default by focusing the first element that has the autofocus attribute. If none is found, the first child element in the tab order is focused.

I could see this being especially helpful in the context of modals and drawers.

@calebporzio
Copy link
Collaborator

Thanks!

@calebporzio calebporzio merged commit 5ae57f4 into alpinejs:main Jun 7, 2022
@jannisborgers
Copy link

Just wanted to leave a heart. This saved me a ton of work and is super convenient! 👏

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

Successfully merging this pull request may close these issues.

3 participants