Skip to content

Commit 9dff545

Browse files
Handle clicks inside iframes (#2485)
* Handle clicks inside iframes * Update changelog
1 parent 67f3c4d commit 9dff545

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Ensure `FocusTrap` is only active when the given `enabled` value is `true` ([#2456](https://github.com/tailwindlabs/headlessui/pull/2456))
1717
- Stop `<Transition appear>` from overwriting classes on re-render ([#2457](https://github.com/tailwindlabs/headlessui/pull/2457))
1818
- Improve control over `Menu` and `Listbox` options while searching ([#2471](https://github.com/tailwindlabs/headlessui/pull/2471))
19+
- Consider clicks inside iframes to be "outside" ([#2485](https://github.com/tailwindlabs/headlessui/pull/2485))
1920

2021
### Changed
2122

packages/@headlessui-react/src/hooks/use-outside-click.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { MutableRefObject, useEffect, useRef } from 'react'
22
import { FocusableMode, isFocusableElement } from '../utils/focus-management'
33
import { useDocumentEvent } from './use-document-event'
4+
import { useWindowEvent } from './use-window-event'
45

56
type Container = MutableRefObject<HTMLElement | null> | HTMLElement | null
67
type ContainerCollection = Container[] | Set<Container>
@@ -136,7 +137,7 @@ export function useOutsideClick(
136137
// In this case we care only about the first case so we check to see if the active element is the iframe
137138
// If so this was because of a click, focus, or other interaction with the child iframe
138139
// and we can consider it an "outside click"
139-
useDocumentEvent(
140+
useWindowEvent(
140141
'blur',
141142
(event) =>
142143
handleOutsideClick(event, () =>

packages/@headlessui-vue/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Ensure `FocusTrap` is only active when the given `enabled` value is `true` ([#2456](https://github.com/tailwindlabs/headlessui/pull/2456))
1414
- Ensure the exposed `activeIndex` is up to date for the `Combobox` component ([#2463](https://github.com/tailwindlabs/headlessui/pull/2463))
1515
- Improve control over `Menu` and `Listbox` options while searching ([#2471](https://github.com/tailwindlabs/headlessui/pull/2471))
16+
- Consider clicks inside iframes to be "outside" ([#2485](https://github.com/tailwindlabs/headlessui/pull/2485))
1617

1718
### Changed
1819

packages/@headlessui-vue/src/hooks/use-outside-click.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { computed, Ref, ComputedRef, ref } from 'vue'
22
import { FocusableMode, isFocusableElement } from '../utils/focus-management'
33
import { dom } from '../utils/dom'
44
import { useDocumentEvent } from './use-document-event'
5+
import { useWindowEvent } from './use-window-event'
56

67
type Container = Ref<HTMLElement | null> | HTMLElement | null
78
type ContainerCollection = Container[] | Set<Container>
@@ -122,7 +123,7 @@ export function useOutsideClick(
122123
// In this case we care only about the first case so we check to see if the active element is the iframe
123124
// If so this was because of a click, focus, or other interaction with the child iframe
124125
// and we can consider it an "outside click"
125-
useDocumentEvent(
126+
useWindowEvent(
126127
'blur',
127128
(event) =>
128129
handleOutsideClick(event, () =>

0 commit comments

Comments
 (0)