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

Fix crash when reading headlessuiFocusGuard of relatedTarget in the FocusTrap component #2203

Merged
merged 2 commits into from
Jan 24, 2023

Conversation

RobinMalfait
Copy link
Member

This PR fixes a crash when the FocusTrap is blurred and the relatedTarget is not and HTMLElement.

I was assuming that this was always an HTMLElement or null but that's not the case. Just using e.relatedTarget shows that dataset is not always available.

Fixes: #2196

@vercel
Copy link

vercel bot commented Jan 24, 2023

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

Name Status Preview Comments Updated
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 24, 2023 at 7:07PM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 24, 2023 at 7:07PM (UTC)

Or in other words, Robin trust the type system...

I was assuming that this was always an `HTMLElement` or `null` but
that's not the case. Just using `e.relatedTarget` shows that `dataset`
is not always available.
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.

Cannot read properties of undefined (reading 'headlessuiFocusGuard') in 1.7.6+
1 participant