Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
],
"type": "module",
"types": "dist/index.d.ts",
"version": "0.20261125.5",
"version": "0.20261125.6",
"exports": {
".": {
"types": "./dist/index.d.ts",
Expand Down
11 changes: 10 additions & 1 deletion src/widgets/ContextMenuWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@ const show = async (event: MouseEvent, usingKeyboard: boolean = false): Promise<
// update: the focused item of a level remains focused (even if it has moved) as long as it can be identified, and
// so does an open submenu as long as its parent item can be identified and still has a submenu. Otherwise, that
// item is no longer focused (so that choosing the focused item can never run another action than the one that was
// focused) and that submenu gets closed. We then position our levels again since their size may have changed.
// focused) and that submenu gets closed. If that submenu had the keyboard focus, then the focus would be lost
// (since that submenu's list is gone), so we give it to our last remaining level, so that our context menu can
// still be used with the keyboard (and hidden using Escape). We then position our levels again since their size
// may have changed.

const actionIndexes = (items: ContextMenuItem[], label: string): number[] => {
// Return the indexes of the actions with the given label in the given items.
Expand Down Expand Up @@ -527,10 +530,16 @@ const updateLevels = async (items: ContextMenuItem[]): Promise<void> => {
levelItems = parentItem.items;
}

const hadFocus = !!containerRef.value?.contains(document.activeElement);

levels.value = newLevels;

await vue.nextTick();

if (hadFocus && levels.value.length && !containerRef.value?.contains(document.activeElement)) {
focusLevel(levels.value.length - 1);
}

newLevels.forEach((_level: Level, levelIndex: number) => {
positionLevel(levelIndex, anchorX, anchorY);
});
Expand Down