From 319bcbad3bde40a82289dd880a48b49bd2268083 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Tue, 30 Apr 2024 10:40:58 -0400 Subject: [PATCH] Only check for elements in `useInertOthers` (#3154) * Only check for elements in useInertOthers * Update changelog * Update packages/@headlessui-react/CHANGELOG.md --------- Co-authored-by: Jonathan Reinink --- packages/@headlessui-react/CHANGELOG.md | 1 + packages/@headlessui-react/src/hooks/use-inert-others.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/@headlessui-react/CHANGELOG.md b/packages/@headlessui-react/CHANGELOG.md index d7e7362..68ca344 100644 --- a/packages/@headlessui-react/CHANGELOG.md +++ b/packages/@headlessui-react/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `overflow: auto` when using the `anchor` prop ([#3138](https://github.com/tailwindlabs/headlessui/pull/3138)) - Ensure `TransitionRoot` component without props transitions correctly ([#3147](https://github.com/tailwindlabs/headlessui/pull/3147)) - Ensure the `static` and `portal` props work nicely together ([#3152](https://github.com/tailwindlabs/headlessui/pull/3152)) +- Only check for elements in `useInertOthers` ([#3154](https://github.com/tailwindlabs/headlessui/pull/3154)) ### Changed diff --git a/packages/@headlessui-react/src/hooks/use-inert-others.tsx b/packages/@headlessui-react/src/hooks/use-inert-others.tsx index 7f96149..6d8e541 100644 --- a/packages/@headlessui-react/src/hooks/use-inert-others.tsx +++ b/packages/@headlessui-react/src/hooks/use-inert-others.tsx @@ -103,7 +103,7 @@ export function useInertOthers( let parent = element.parentElement while (parent && parent !== ownerDocument.body) { // Mark all siblings as inert - for (let node of parent.childNodes) { + for (let node of parent.children) { // If the node contains any of the elements we should not mark it as inert // because it would make the elements unreachable. if (allowedElements.some((el) => node.contains(el))) continue