Skip to content

Commit 1c60c68

Browse files
authored
fix(onClickOutside): workaround for iOS (#4735)
1 parent a16bfb0 commit 1c60c68

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/core/onClickOutside/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ export function onClickOutside(
8484
if (isIOS && !_iOSWorkaround) {
8585
_iOSWorkaround = true
8686
const listenerOptions = { passive: true }
87+
// Not using useEventListener because this event handlers must not be disposed.
88+
// See previusly linked references and https://github.com/vueuse/vueuse/issues/4724
8789
Array.from(window.document.body.children)
88-
.forEach(el => useEventListener(el, 'click', noop, listenerOptions))
89-
useEventListener(window.document.documentElement, 'click', noop, listenerOptions)
90+
.forEach(el => el.addEventListener('click', noop, listenerOptions))
91+
window.document.documentElement.addEventListener('click', noop, listenerOptions)
9092
}
9193

9294
let shouldListen = true

0 commit comments

Comments
 (0)