From ff9bd10375cf61285d208319dff5ec119eea64b1 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 9 Sep 2024 16:53:55 +0200 Subject: [PATCH] fix: listen just once for escape key in contextmenu --- umap/static/umap/js/modules/ui/contextmenu.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/umap/static/umap/js/modules/ui/contextmenu.js b/umap/static/umap/js/modules/ui/contextmenu.js index c5c47555..fd61c84a 100644 --- a/umap/static/umap/js/modules/ui/contextmenu.js +++ b/umap/static/umap/js/modules/ui/contextmenu.js @@ -43,12 +43,16 @@ export default class ContextMenu extends Positioned { this.computePosition([left, top]) } this.container.querySelector('li > *').focus() - this.container.addEventListener('keydown', (event) => { - if (event.key === 'Escape') { - event.stopPropagation() - this.close() - } - }) + this.container.addEventListener( + 'keydown', + (event) => { + if (event.key === 'Escape') { + event.stopPropagation() + this.close() + } + }, + { once: true } + ) } close() {