File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
packages/core/onClickOutside Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,19 @@ useEventListener('pointermove', (e) => {
44
44
})
45
45
```
46
46
47
+ If you want to ignore certain elements, you can use the ` ignore ` option. Provide the elements to ignore as an array of Refs or CSS Selectors.
48
+
49
+ ``` ts
50
+ const ignoreElRef = useTemplateRef <HTMLElement >(' ignoreEl' )
51
+ const ignoreElSelector = ' .ignore-el'
52
+
53
+ onClickOutside (
54
+ target ,
55
+ event => console .log (event ),
56
+ { ignore: [ignoreElRef , ignoreElSelector ] },
57
+ )
58
+ ```
59
+
47
60
## Component Usage
48
61
49
62
``` vue
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import { useEventListener } from '../useEventListener'
10
10
11
11
export interface OnClickOutsideOptions < Controls extends boolean = false > extends ConfigurableWindow {
12
12
/**
13
- * List of elements that should not trigger the event.
13
+ * List of elements that should not trigger the event,
14
+ * provided as Refs or CSS Selectors.
14
15
*/
15
16
ignore ?: MaybeRefOrGetter < ( MaybeElementRef | string ) [ ] >
16
17
/**
@@ -84,8 +85,8 @@ export function onClickOutside(
84
85
if ( isIOS && ! _iOSWorkaround ) {
85
86
_iOSWorkaround = true
86
87
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
88
+ // Not using useEventListener because these event handlers must not be disposed.
89
+ // See previously linked references and https://github.com/vueuse/vueuse/issues/4724
89
90
Array . from ( window . document . body . children )
90
91
. forEach ( el => el . addEventListener ( 'click' , noop , listenerOptions ) )
91
92
window . document . documentElement . addEventListener ( 'click' , noop , listenerOptions )
You can’t perform that action at this time.
0 commit comments