menu: close when clicking outside in toggle mode
This commit is contained in:
parent
c795c731bb
commit
e29e5f83cb
1 changed files with 14 additions and 0 deletions
|
|
@ -122,6 +122,11 @@ class Menu extends Widget {
|
|||
} else {
|
||||
|
||||
this.menu.classList.add('norelease')
|
||||
this.toggleCloseHandler = (e)=>{
|
||||
if (!this.opened || this.menu.contains(e.target)) return
|
||||
this.close()
|
||||
}
|
||||
document.addEventListener('fast-click', this.toggleCloseHandler)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -310,6 +315,15 @@ class Menu extends Widget {
|
|||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
|
||||
if (this.getProp('toggle')) {
|
||||
document.removeEventListener('fast-click', this.toggleCloseHandler)
|
||||
}
|
||||
super.onRemove()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Menu.dynamicProps = Menu.prototype.constructor.dynamicProps.concat(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue