Skip to content

Commit

Permalink
fix(cdk:click-outside): not working when click target has @click.stop (
Browse files Browse the repository at this point in the history
  • Loading branch information
hangboss1761 committed May 6, 2022
1 parent 1377fff commit a400cba
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/cdk/click-outside/src/useClickOutside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,20 @@ interface DocumentHandlerOptions {

const documentHandlerMap = new Map<HTMLElement, DocumentHandlerOptions>()

on(document, 'click', event => {
documentHandlerMap.forEach(({ exclude, handler }) => {
const target = event.target as Node
if (exclude.some(item => item === target || item.contains(target))) {
return
}
handler(event)
})
})
on(
document,
'click',
event => {
documentHandlerMap.forEach(({ exclude, handler }) => {
const target = event.target as Node
if (exclude.some(item => item === target || item.contains(target))) {
return
}
handler(event)
})
},
{ capture: true },
)

function createHandler(el: HTMLElement, binding: ClickOutsideBinding): void {
const exclude: HTMLElement[] = [el]
Expand Down

0 comments on commit a400cba

Please sign in to comment.