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

Commit

Permalink
chore: Update based on PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
dsappet committed Mar 13, 2021
1 parent bcbe58d commit ad5a22f
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.composedPath ? (e.composedPath()[0] as Node) : (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 ad5a22f

Please sign in to comment.