Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit dd60249

Browse files
authored
feat: Scope action selector keyboard events to focused panel (#1246)
1. Skip keyboard event handling when ActionSelector container is not focused 2. Add focus ring styling to grid cells on focus-within 3. Delegate click on grid cell to focus its ActionSelector
1 parent 51de5b2 commit dd60249

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

apps/code/src/renderer/components/action-selector/ActionSelector.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ export function ActionSelector({
118118
if (showInlineEdit || document.activeElement?.tagName === "TEXTAREA")
119119
return;
120120

121+
const container = containerRef.current;
122+
if (
123+
container &&
124+
container !== document.activeElement &&
125+
!container.contains(document.activeElement)
126+
) {
127+
return;
128+
}
129+
121130
switch (e.key) {
122131
case "ArrowUp":
123132
e.preventDefault();
@@ -186,7 +195,7 @@ export function ActionSelector({
186195
document.addEventListener("keydown", handler, { capture: true });
187196
return () =>
188197
document.removeEventListener("keydown", handler, { capture: true });
189-
}, []);
198+
}, [containerRef.current]);
190199

191200
const getSubmitLabel = () => {
192201
return hasSteps && activeStep < numSteps - 1 ? "Next" : "Submit";

apps/code/src/renderer/features/command-center/components/CommandCenterGrid.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useEffect, useState } from "react";
1+
import { useCallback, useEffect, useRef, useState } from "react";
22
import type { CommandCenterCellData } from "../hooks/useCommandCenterData";
33
import {
44
getGridDimensions,
@@ -51,8 +51,15 @@ function GridCell({
5151
zoom: number;
5252
isDragActive: boolean;
5353
}) {
54+
const cellRef = useRef<HTMLDivElement>(null);
5455
const [isDragOver, setIsDragOver] = useState(false);
5556

57+
const handleCellClick = useCallback(() => {
58+
const actionSelector =
59+
cellRef.current?.querySelector<HTMLElement>("[tabindex='0']");
60+
actionSelector?.focus();
61+
}, []);
62+
5663
const handleDragOver = useCallback((e: React.DragEvent) => {
5764
if (e.dataTransfer.types.includes("text/x-task-id")) {
5865
e.preventDefault();
@@ -78,7 +85,12 @@ function GridCell({
7885
);
7986

8087
return (
81-
<div className="relative overflow-hidden bg-gray-1">
88+
// biome-ignore lint/a11y/useKeyWithClickEvents lint/a11y/noStaticElementInteractions: click delegates focus to ActionSelector within
89+
<div
90+
ref={cellRef}
91+
className="relative overflow-hidden bg-gray-1 focus-within:ring-2 focus-within:ring-accent-9 focus-within:ring-inset"
92+
onClick={handleCellClick}
93+
>
8294
<div
8395
className="h-full w-full origin-top-left"
8496
style={{

0 commit comments

Comments
 (0)