Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #65 from dsappet/bugfix/inside-shadow-dom
Browse files Browse the repository at this point in the history
  • Loading branch information
WickyNilliams authored Mar 19, 2021
2 parents 4a769c6 + ad5a22f commit d94377b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/duet-date-picker/duet-date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ export class DuetDatePicker implements ComponentInterface {
return
}

const target = e.target as Node

// TODO: stopPropagation only on open??

// the dialog and the button aren't considered clicks outside.
Expand All @@ -250,11 +248,14 @@ export class DuetDatePicker implements ComponentInterface {
// and open the new one. this means we can't stopPropagation() on the button itself
//
// this was the only satisfactory combination of things to get the above to work
if (this.dialogWrapperNode.contains(target) || this.datePickerButton.contains(target)) {
return
}

this.hide(false)
const isClickOutside = e
.composedPath()
.every(node => node !== this.dialogWrapperNode && node !== this.datePickerButton)

if (isClickOutside) {
this.hide(false)
}
}

/**
Expand Down

0 comments on commit d94377b

Please sign in to comment.