Skip to content

Fix Restoring Focus in Dialog (#3686) #3687

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jardakotesovec
Copy link

@jardakotesovec jardakotesovec commented Apr 10, 2025

Per my testing fixes #3686

Copy link

vercel bot commented Apr 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 10, 2025 3:25pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 10, 2025 3:25pm

@@ -239,15 +240,16 @@ function useRestoreElement(enabled: Ref<boolean>) {

function useRestoreFocus(
{ ownerDocument }: { ownerDocument: Ref<Document | null> },
enabled: Ref<boolean>
enabled: Ref<boolean>,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats happening here is that, if enabled is also calculated from mounted.value, it:

  1. it hits onUnmounted(() => (mounted.value = false))
  2. that caused recalculating of the computed(() => mounted.value && Boolean(props.features & Features.RestoreFocus))
  3. As result inOnmounted the enabled.value was already false and restoration is skipped

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.

Dialog is not returning focus after updating to vue 3.5
1 participant