fix(web): context menu highlight and pointer handoff follow keyboard focus #18876
main fromrefs/pull/18876/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/contextMenuFallback.ts line 562OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -418,17 +537,7 @@418537 button.addEventListener("mouseenter", () => {538+ if (isKeyboardDriven) return;539+ isFocusRevealed = true;419540 button.focus({ preventScroll: true });420- isHovered = true;421- updateHighlight();422- });423- button.addEventListener("mouseleave", () => {424- isHovered = false;425- updateHighlight();426- });427- button.addEventListener("focus", () => {428- isFocused = true;429- updateHighlight();430- });431- button.addEventListener("blur", () => {432- isFocused = false;433- updateHighlight();541+ refreshHighlights();434542 });543+ button.addEventListener("focus", updateHighlight);
coderabbitai[bot](GitHub profile, opens in a new tab) requested changes
apps/web/src/contextMenuFallback.ts lines 364 to 377OutdatedResolvedby TonybynMp4(GitHub profile, opens in a new tab)@@ -262 +330,21 @@330+ if (items[focusedIndex]?.getAttribute("aria-haspopup") !== "menu") return;331+ items[focusedIndex]?.click();332+ break;333+ case "ArrowLeft":334+ if (level === 0) return;335+ closeMenusFromLevel(level);336+ break;337+ case "Escape":338+ if (level === 0) {339+ cleanup(null);340+ } else {341+ closeMenusFromLevel(level);342+ }343+ break;344+ case "Tab":345+ cleanup(null);346+ break;347+ default:348+ return;262349 }350+ event.preventDefault();juliusmarminge added labelsmacroscope-review
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
- apps/web/src/contextMenuFallback.ts lines 330 to 335OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -260,2 +304,20 @@304+ cleanup(null);305+ }306+ return;307+ }308+ const items = enabledItems(menu);309+ const focusedIndex = items.findIndex((item) => item === document.activeElement);310+ // The first ArrowDown on a quiet open reveals the focused first item311+ // rather than skipping past it.312+ if (!isFocusRevealed && event.key === "ArrowDown" && focusedIndex !== -1) {260313 event.preventDefault();261- cleanup(null);314+ isKeyboardDriven = true;315+ isFocusRevealed = true;316+ refreshHighlights();317+ return;318+ }319+ const focusItem = (index: number) => {320+ const item = items[(index + items.length) % items.length];321+ item?.focus({ preventScroll: true });322+ item?.scrollIntoView({ block: "nearest" });323+ };
juliusmarminge assignedjuliusmarminge
juliusmarminge added labelstakeover
juliusmarminge added labelspr:in-progress
juliusmarminge added labelspr:needs-julius
juliusmarminge removed labelspr:in-progress
TonybynMp4(GitHub profile, opens in a new tab) changed the title
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed