Skip to content

Commit bce1556

Browse files
committed
Merge branch 'main' into bug-fix/8686/table-cell-incorrectly-returns-focus-to-button
2 parents adbba17 + b1af29c commit bce1556

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

packages/react-aria/src/grid/useGridCell.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,14 @@ export function useGridCell<T, C extends GridCollection<T>>(
264264
}
265265

266266
if (focusMode === 'child') {
267-
// Wrap in requestAnimationFrame to ensure real browsers have fully
268-
// updated document.activeElement after focus propagation completes.
269-
requestAnimationFrame(() => {
270-
let activeElement = getActiveElement();
271-
if (ref.current && isFocusWithin(ref.current) && activeElement !== ref.current) {
272-
return;
273-
}
274-
focus();
275-
});
267+
// If the cell itself is focused, verify the active element state
268+
// before determining if focus needs to fallback to a child element.
269+
let activeElement = getActiveElement();
270+
if (ref.current && isFocusWithin(ref.current) && activeElement !== ref.current) {
271+
return;
272+
}
273+
274+
focus();
276275
}
277276
};
278277

0 commit comments

Comments
 (0)