Skip to content

Commit

Permalink
mhutchie#557 Improved context menu click event handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhutchie authored and homsai committed Sep 7, 2022
1 parent ad83208 commit 3409cdd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions web/contextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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((<HTMLElement>(<Element>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);
Expand Down

0 comments on commit 3409cdd

Please sign in to comment.