From d7f43f429a9e024e896bac9fc65fdc530935c812 Mon Sep 17 00:00:00 2001 From: Michael Hutchison Date: Sun, 19 Sep 2021 18:29:55 +1000 Subject: [PATCH] #557 Improved context menu click event handling. --- web/contextMenu.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/contextMenu.ts b/web/contextMenu.ts index 927d771c..5675e492 100644 --- a/web/contextMenu.ts +++ b/web/contextMenu.ts @@ -89,11 +89,17 @@ class ContextMenu { this.onClose = onClose; addListenerToClass('contextMenuItem', 'click', (e) => { + // The user clicked on a context menu item => call the corresponding handler e.stopPropagation(); this.close(); handlers[parseInt(((e.target).closest('.contextMenuItem')!).dataset.index!)](); }); + menu.addEventListener('click', (e) => { + // The user clicked on the context menu (but not a specific item) => keep the context menu open to allow the user to reattempt clicking on a specific item + e.stopPropagation(); + }); + this.target = target; if (this.target !== null && this.target.type !== TargetType.Repo) { alterClass(this.target.elem, CLASS_CONTEXT_MENU_ACTIVE, true);