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

🐛 Bug Report: Focus not reset to trigger button after closing Dialog in Nuxt 3 #3535

Open
Archetipo95 opened this issue Oct 18, 2024 · 1 comment

Comments

@Archetipo95
Copy link

Description

I'm experiencing an issue with focus management in the Dialog component when using Headless UI in a Nuxt 3 project. When I open a dialog and then close it, the focus is not reset to the button that opened the dialog. Instead, the focus seems to be lost, and the last focused item appears to be the close button inside the dialog, even though the button no longer exists in the DOM.

Steps to Reproduce

🛠️ Create a Nuxt 3 project using the latest version.
📦 Install Headless UI (latest version).
📄 Use the Dialog component as provided in the documentation examples.
🔘 Open the dialog by clicking a button.
❌ Close the dialog.

Expected Behavior

After closing the dialog, the focus should be reset to the button that triggered the dialog.

Actual Behavior

The focus is lost, and the last focused item is the close button inside the dialog, which no longer exists.

Code Example

Here is a minimal reproducible example (POC) demonstrating the issue:
GitHub Repository

Live demo: Netlify Deployment

Workaround

I noticed that if I use the :open="isOpen" prop on the Dialog component, the focus is maintained correctly, but the closing transition is interrupted and does not work smoothly.

Screenshots/Videos

Screen.Recording.2024-10-18.at.16.14.42.mov
@Archetipo95
Copy link
Author

@RobinMalfait I would like to ask you for a feedback or someone that we can ask for more info. This issue is important because is breaking accessibility for users that use screen readers or users that navigate with keyboard

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

No branches or pull requests

1 participant