Skip to content

Commit d7f43f4

Browse files
committed
mhutchie#557 Improved context menu click event handling.
1 parent 5b8c7ca commit d7f43f4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

web/contextMenu.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,17 @@ class ContextMenu {
8989
this.onClose = onClose;
9090

9191
addListenerToClass('contextMenuItem', 'click', (e) => {
92+
// The user clicked on a context menu item => call the corresponding handler
9293
e.stopPropagation();
9394
this.close();
9495
handlers[parseInt((<HTMLElement>(<Element>e.target).closest('.contextMenuItem')!).dataset.index!)]();
9596
});
9697

98+
menu.addEventListener('click', (e) => {
99+
// 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
100+
e.stopPropagation();
101+
});
102+
97103
this.target = target;
98104
if (this.target !== null && this.target.type !== TargetType.Repo) {
99105
alterClass(this.target.elem, CLASS_CONTEXT_MENU_ACTIVE, true);

0 commit comments

Comments
 (0)