From f77e4493f84faf0d81771c998be6f2f0205a7ed0 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sat, 26 Oct 2024 14:46:12 +0200 Subject: [PATCH] :wrench: Prevent unwanted selections in marking mode --- src/renderer/menu/menu.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/renderer/menu/menu.ts b/src/renderer/menu/menu.ts index d41f5fce..9ca1a6d5 100644 --- a/src/renderer/menu/menu.ts +++ b/src/renderer/menu/menu.ts @@ -345,11 +345,20 @@ export class Menu extends EventEmitter { return; } - // If there is an item currently dragged, select it. We only select items which have - // children in marking mode in order to prevent unwanted actions. This way the user - // can always check if the correct action was selected before executing it. + // If there is an item currently dragged, select it. If we are in Marking Mode or + // Turbo Mode, the selection type will be eSubmenuOnly. In this case, we only select + // subemnus in order to prevent unwanted actions. This way the user can always check + // if the correct action was selected before executing it. + // We also do not trigger selections of the parent item when moving the mouse in the + // center zone of the menu. This feels more natural and prevents accidental + // selections. const item = this.hoveredItem || this.clickedItem || this.draggedItem; - if (type === SelectionType.eSubmenuOnly && item && item.children?.length > 0) { + if ( + type === SelectionType.eSubmenuOnly && + item && + item.type === 'submenu' && + this.latestInput.distance > this.options.centerDeadZone + ) { this.selectItem(item, coords); return; }