fix: listen just once for escape key in contextmenu

This commit is contained in:
Yohan Boniface 2024-09-09 16:53:55 +02:00
parent 1029c2655e
commit 6876bb1ba5

View file

@ -43,12 +43,16 @@ export default class ContextMenu extends Positioned {
this.computePosition([left, top]) this.computePosition([left, top])
} }
this.container.querySelector('li > *').focus() this.container.querySelector('li > *').focus()
this.container.addEventListener('keydown', (event) => { this.container.addEventListener(
'keydown',
(event) => {
if (event.key === 'Escape') { if (event.key === 'Escape') {
event.stopPropagation() event.stopPropagation()
this.close() this.close()
} }
}) },
{ once: true }
)
} }
close() { close() {