diff --git a/packages/@headlessui-react/CHANGELOG.md b/packages/@headlessui-react/CHANGELOG.md index 5105bde..db9b4eb 100644 --- a/packages/@headlessui-react/CHANGELOG.md +++ b/packages/@headlessui-react/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ensure `FocusTrap` is only active when the given `enabled` value is `true` ([#2456](https://github.com/tailwindlabs/headlessui/pull/2456)) - Stop `` from overwriting classes on re-render ([#2457](https://github.com/tailwindlabs/headlessui/pull/2457)) - Improve control over `Menu` and `Listbox` options while searching ([#2471](https://github.com/tailwindlabs/headlessui/pull/2471)) +- Consider clicks inside iframes to be "outside" ([#2485](https://github.com/tailwindlabs/headlessui/pull/2485)) ### Changed diff --git a/packages/@headlessui-react/src/hooks/use-outside-click.ts b/packages/@headlessui-react/src/hooks/use-outside-click.ts index a6e2406..f023310 100644 --- a/packages/@headlessui-react/src/hooks/use-outside-click.ts +++ b/packages/@headlessui-react/src/hooks/use-outside-click.ts @@ -1,6 +1,7 @@ import { MutableRefObject, useEffect, useRef } from 'react' import { FocusableMode, isFocusableElement } from '../utils/focus-management' import { useDocumentEvent } from './use-document-event' +import { useWindowEvent } from './use-window-event' type Container = MutableRefObject | HTMLElement | null type ContainerCollection = Container[] | Set @@ -136,7 +137,7 @@ export function useOutsideClick( // In this case we care only about the first case so we check to see if the active element is the iframe // If so this was because of a click, focus, or other interaction with the child iframe // and we can consider it an "outside click" - useDocumentEvent( + useWindowEvent( 'blur', (event) => handleOutsideClick(event, () => diff --git a/packages/@headlessui-vue/CHANGELOG.md b/packages/@headlessui-vue/CHANGELOG.md index c827893..f1b0c20 100644 --- a/packages/@headlessui-vue/CHANGELOG.md +++ b/packages/@headlessui-vue/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ensure `FocusTrap` is only active when the given `enabled` value is `true` ([#2456](https://github.com/tailwindlabs/headlessui/pull/2456)) - Ensure the exposed `activeIndex` is up to date for the `Combobox` component ([#2463](https://github.com/tailwindlabs/headlessui/pull/2463)) - Improve control over `Menu` and `Listbox` options while searching ([#2471](https://github.com/tailwindlabs/headlessui/pull/2471)) +- Consider clicks inside iframes to be "outside" ([#2485](https://github.com/tailwindlabs/headlessui/pull/2485)) ### Changed diff --git a/packages/@headlessui-vue/src/hooks/use-outside-click.ts b/packages/@headlessui-vue/src/hooks/use-outside-click.ts index e4d6b51..084eedb 100644 --- a/packages/@headlessui-vue/src/hooks/use-outside-click.ts +++ b/packages/@headlessui-vue/src/hooks/use-outside-click.ts @@ -2,6 +2,7 @@ import { computed, Ref, ComputedRef, ref } from 'vue' import { FocusableMode, isFocusableElement } from '../utils/focus-management' import { dom } from '../utils/dom' import { useDocumentEvent } from './use-document-event' +import { useWindowEvent } from './use-window-event' type Container = Ref | HTMLElement | null type ContainerCollection = Container[] | Set @@ -122,7 +123,7 @@ export function useOutsideClick( // In this case we care only about the first case so we check to see if the active element is the iframe // If so this was because of a click, focus, or other interaction with the child iframe // and we can consider it an "outside click" - useDocumentEvent( + useWindowEvent( 'blur', (event) => handleOutsideClick(event, () =>