File tree Expand file tree Collapse file tree
apps/code/src/renderer/components/action-selector Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ function isInteractiveElementInDifferentCell(
2828
2929 const activeCell = el . closest ( "[data-grid-cell]" ) ;
3030 const ownCell = containerRef . current ?. closest ( "[data-grid-cell]" ) ;
31+
32+ // Outside a grid (single-task mode): block focus steal from any interactive element.
33+ // Inside a grid: only block when the interactive element is in a different cell.
3134 if ( ! activeCell || ! ownCell ) return true ;
3235
3336 return activeCell !== ownCell ;
@@ -72,6 +75,7 @@ export function useActionSelectorState({
7275 ( ) => new Map ( ) ,
7376 ) ;
7477 const containerRef = useRef < HTMLDivElement > ( null ) ;
78+ const prevActiveStepRef = useRef ( currentStep ) ;
7579
7680 const activeStep = internalStep ;
7781 const hasSteps = steps !== undefined && steps . length > 1 ;
@@ -152,6 +156,8 @@ export function useActionSelectorState({
152156 ) ;
153157
154158 useEffect ( ( ) => {
159+ if ( activeStep === prevActiveStepRef . current ) return ;
160+ prevActiveStepRef . current = activeStep ;
155161 restoreStepAnswer ( activeStep , {
156162 autoFocus : ! isInteractiveElementInDifferentCell ( containerRef ) ,
157163 } ) ;
You can’t perform that action at this time.
0 commit comments