Handle clicks inside iframes (#2485)
* Handle clicks inside iframes * Update changelog
This commit is contained in:
@@ -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 `<Transition appear>` 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
|
||||
|
||||
|
||||
@@ -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> | HTMLElement | null
|
||||
type ContainerCollection = Container[] | Set<Container>
|
||||
@@ -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, () =>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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> | HTMLElement | null
|
||||
type ContainerCollection = Container[] | Set<Container>
|
||||
@@ -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, () =>
|
||||
|
||||
Reference in New Issue
Block a user