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

[Feature]: Focus trigger on dialog close #921

Closed
2 tasks done
enkot opened this issue May 14, 2024 · 2 comments · Fixed by #922
Closed
2 tasks done

[Feature]: Focus trigger on dialog close #921

enkot opened this issue May 14, 2024 · 2 comments · Fixed by #922

Comments

@enkot
Copy link
Contributor

enkot commented May 14, 2024

Describe the feature

Currently, if a dialog is controlled by modelValue and does not use the DialogTrigger, focus cannot be handled properly (move focus back to the trigger after closing).
I suggest adding a triggerElement prop to the DialogRoot so that the user can specify which trigger was used to open the dialog.

Additional information

  • I intend to submit a PR for this feature.
  • I have already implemented and/or tested this feature.
@zernonia
Copy link
Collaborator

zernonia commented May 15, 2024

Thanks for the issue and PR @enkot . However I have different solution in mind, similar to Headless UI.. perhaps internally we can track the previous focus target, and focus on it again when the dialog close.

This way, user might need to not set additional prop, and have a more consistent behaviour. Imagine 2 buttons could trigger the same dialog.

@enkot
Copy link
Contributor Author

enkot commented May 15, 2024

I agree, it will be a better solution.

@enkot enkot changed the title [Feature]: Add triggerElement prop to the DialogRoot [Feature]: Focus trigger on dialog close May 15, 2024
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 a pull request may close this issue.

2 participants