Skip to content

Commit

Permalink
Fix #112 (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
germain-receeve committed Jan 29, 2020
1 parent 1ebaa81 commit 63b89b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@
},
"engines": {
"node": ">=6"
},
"dependencies": {
"event-propagation-path": "^1.0.5"
}
}
8 changes: 7 additions & 1 deletion src/v-click-outside.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'event-propagation-path'

const HANDLERS_PROPERTY = '__v-click-outside'
const HAS_WINDOWS = typeof window !== 'undefined'
const HAS_NAVIGATOR = typeof navigator !== 'undefined'
Expand All @@ -24,7 +26,11 @@ function processDirectiveArguments(bindingValue) {
}

function onEvent({ el, event, handler, middleware }) {
const isClickOutside = event.target !== el && !el.contains(event.target)
const outsideCheck = event.propagationPath
? event.propagationPath().indexOf(el) < 0
: !el.contains(event.target)

const isClickOutside = event.target !== el && outsideCheck

if (!isClickOutside) {
return
Expand Down

0 comments on commit 63b89b4

Please sign in to comment.