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

Focus trap doesn't release focus when the element is removed from the dom #2682

Merged
merged 2 commits into from Mar 1, 2022

Conversation

SimoTod
Copy link
Collaborator

@SimoTod SimoTod commented Feb 17, 2022

If the focus trap is active and the element is removed from the dom, focus doesn't get released and tabbing around the page becomes impossible. This happens in Alpine if the focus is combined to x-if.

<div x-data="{ open: false }">
    <button @click="open = true">open</button>
    <template x-if="open">
        <div x-trap="open">
            <button @click="open = false">close</button>
        </div>
    </template>
</div>

Before https://github.com/alpinejs/alpine/pull/2556/files this was coincidentally working because the effect wasn't released correctly but it doesn't work anymore in v3.9.0

@calebporzio
Copy link
Collaborator

Perfect, thanks @SimoTod !!

@calebporzio calebporzio merged commit 4b7e912 into alpinejs:main Mar 1, 2022
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.

None yet

2 participants