Fix crash when reading headlessuiFocusGuard of relatedTarget in the FocusTrap component (#2203)
* ensure `relatedTarget` is an `HTMLElement` 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. * update changelog
This commit is contained in:
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Fix `failed to removeChild on Node` bug ([#2164](https://github.com/tailwindlabs/headlessui/pull/2164))
|
||||
- Don’t overwrite classes during SSR when rendering fragments ([#2173](https://github.com/tailwindlabs/headlessui/pull/2173))
|
||||
- Improve `Combobox` accessibility ([#2153](https://github.com/tailwindlabs/headlessui/pull/2153))
|
||||
- Fix crash when reading `headlessuiFocusGuard` of `relatedTarget` in the `FocusTrap` component ([#2203](https://github.com/tailwindlabs/headlessui/pull/2203))
|
||||
|
||||
## [1.7.7] - 2022-12-16
|
||||
|
||||
|
||||
@@ -109,8 +109,8 @@ export let FocusTrap = Object.assign(
|
||||
let allContainers = new Set(containers?.current)
|
||||
allContainers.add(container)
|
||||
|
||||
let relatedTarget = e.relatedTarget as HTMLElement | null
|
||||
if (!relatedTarget) return
|
||||
let relatedTarget = e.relatedTarget
|
||||
if (!(relatedTarget instanceof HTMLElement)) return
|
||||
|
||||
// Known guards, leave them alone!
|
||||
if (relatedTarget.dataset.headlessuiFocusGuard === 'true') {
|
||||
|
||||
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Fix `Tab` key with non focusable elements in `Popover.Panel` ([#2147](https://github.com/tailwindlabs/headlessui/pull/2147))
|
||||
- Don’t overwrite classes during SSR when rendering fragments ([#2173](https://github.com/tailwindlabs/headlessui/pull/2173))
|
||||
- Improve `Combobox` accessibility ([#2153](https://github.com/tailwindlabs/headlessui/pull/2153))
|
||||
- Fix crash when reading `headlessuiFocusGuard` of `relatedTarget` in the `FocusTrap` component ([#2203](https://github.com/tailwindlabs/headlessui/pull/2203))
|
||||
|
||||
## [1.7.7] - 2022-12-16
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ export let FocusTrap = Object.assign(
|
||||
let allContainers = new Set(props.containers?.value)
|
||||
allContainers.add(container)
|
||||
|
||||
let relatedTarget = e.relatedTarget as HTMLElement | null
|
||||
if (!relatedTarget) return
|
||||
let relatedTarget = e.relatedTarget
|
||||
if (!(relatedTarget instanceof HTMLElement)) return
|
||||
|
||||
// Known guards, leave them alone!
|
||||
if (relatedTarget.dataset.headlessuiFocusGuard === 'true') {
|
||||
|
||||
Reference in New Issue
Block a user