radix-vue / radix-vue

Vue port of Radix UI Primitives. An open-source UI component library for building high-quality, accessible design systems and web apps.

Home Page:https://radix-vue.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature]: Focus trigger on dialog close

enkot opened this issue · comments

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.

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.

I agree, it will be a better solution.