Add right-click menu to issue and patch lists

This commit is contained in:
Brandon Oxendine
2026-10-20 15:44:56 +02:00
committed by Rūdolfs Ošiņš
parent 95405a07cb
commit 41e5b96b09
16 changed files with 942 additions and 23 deletions
+23
View File
@@ -17,3 +17,26 @@ export function menuFocusIndex(
return undefined;
}
}
export const menuItemSelector = '[role="menuitem"], [role="menuitemcheckbox"]';
// Whether `item` belongs to `menu` itself rather than to a nested submenu.
export function isOwnMenuItem(menu: HTMLElement, item: Element): boolean {
return item.parentElement?.closest('[role="menu"]') === menu;
}
export function ownMenuItems(menu: HTMLElement | undefined): HTMLElement[] {
if (!menu) return [];
return Array.from(
menu.querySelectorAll<HTMLElement>(menuItemSelector),
).filter(item => isOwnMenuItem(menu, item));
}
export function focusMenuItem(ev: KeyboardEvent, items: HTMLElement[]) {
if (items.length === 0) return;
const current = items.findIndex(el => el === document.activeElement);
const next = menuFocusIndex(ev.key, current, items.length);
if (next === undefined) return;
ev.preventDefault();
items[next].focus();
}