@@ -661,7 +661,9 @@ export interface CellRenderProps {
661661 * Whether the cell is currently hovered with a mouse.
662662 * @selector [data-hovered]
663663 */
664- isHovered : boolean
664+ isHovered : boolean ,
665+ /** Whether the cell's children have keyboard focus. */
666+ isFocusVisibleWithin : boolean
665667}
666668
667669export interface CellProps extends RenderProps < CellRenderProps > {
@@ -1020,6 +1022,8 @@ function TableRow<T>({item}: {item: GridNode<T>}) {
10201022 ref
10211023 ) ;
10221024 let { isFocused, isFocusVisible, focusProps} = useFocusRing ( ) ;
1025+ // TODO: would we also want to to check isFocusWithin as well?
1026+ // TODO: Should isFocusVisible be (isFocusVisible || isFocusVisibleWithin) or should they exist as separate states
10231027 let {
10241028 isFocusVisible : isFocusVisibleWithin ,
10251029 focusProps : focusWithinProps
@@ -1161,6 +1165,10 @@ function TableCell<T>({cell}: {cell: GridNode<T>}) {
11611165 shouldSelectOnPressUp : ! ! dragState
11621166 } , state , ref ) ;
11631167 let { isFocused, isFocusVisible, focusProps} = useFocusRing ( ) ;
1168+ let {
1169+ isFocusVisible : isFocusVisibleWithin ,
1170+ focusProps : focusWithinProps
1171+ } = useFocusRing ( { within : true } ) ;
11641172 let { hoverProps, isHovered} = useHover ( { } ) ;
11651173
11661174 let props : CellProps = cell . props ;
@@ -1172,18 +1180,20 @@ function TableCell<T>({cell}: {cell: GridNode<T>}) {
11721180 isFocused,
11731181 isFocusVisible,
11741182 isPressed,
1175- isHovered
1183+ isHovered,
1184+ isFocusVisibleWithin
11761185 }
11771186 } ) ;
11781187
11791188 return (
11801189 < td
1181- { ...mergeProps ( filterDOMProps ( props as any ) , gridCellProps , focusProps , hoverProps ) }
1190+ { ...mergeProps ( filterDOMProps ( props as any ) , gridCellProps , focusProps , hoverProps , focusWithinProps ) }
11821191 { ...renderProps }
11831192 ref = { ref }
11841193 data-focused = { isFocused || undefined }
11851194 data-focus-visible = { isFocusVisible || undefined }
1186- data-pressed = { isPressed || undefined } >
1195+ data-pressed = { isPressed || undefined }
1196+ data-focus-visible-within = { isFocusVisibleWithin || undefined } >
11871197 { renderProps . children }
11881198 </ td >
11891199 ) ;
0 commit comments