Skip to content

Commit

Permalink
🔧 Prevent unwanted selections in marking mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Schneegans committed Oct 26, 2024
1 parent 2548c51 commit f77e449
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/renderer/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f77e449

Please sign in to comment.