| 255 | // Grid cells can have focusable elements inside them. In this case, focus should |
| 256 | // be marshalled to that element rather than focusing the cell itself. |
| 257 | let onFocus = e => { |
| 258 | keyWhenFocused.current = node.key; |
| 259 | if (getEventTarget(e) !== ref.current) { |
| 260 | // useSelectableItem only handles setting the focused key when |
| 261 | // the focused element is the gridcell itself. We also want to |
| 262 | // set the focused key when a child element receives focus. |
| 263 | // If focus is currently visible (e.g. the user is navigating with the keyboard), |
| 264 | // then skip this. We want to restore focus to the previously focused row/cell |
| 265 | // in that case since the table should act like a single tab stop. |
| 266 | if (!isFocusVisible()) { |
| 267 | state.selectionManager.setFocusedKey(node.key); |
| 268 | } |
| 269 | return; |
| 270 | } |
| 271 | |
| 272 | // If the cell itself is focused, wait a frame so that focus finishes propagatating |
| 273 | // up to the tree, and move focus to a focusable child if possible. |
| 274 | requestAnimationFrame(() => { |
| 275 | if (focusMode === 'child' && getActiveElement() === ref.current) { |
| 276 | focus(); |
| 277 | } |
| 278 | }); |
| 279 | }; |
| 280 | |
| 281 | let gridCellProps: DOMAttributes = mergeProps(itemProps, { |
| 282 | role: 'gridcell', |
nothing calls this directly
no test coverage detected