()
| 92 | // Handles focusing the cell. If there is a focusable child, |
| 93 | // it is focused, otherwise the cell itself is focused. |
| 94 | let focus = () => { |
| 95 | if (ref.current) { |
| 96 | let treeWalker = getFocusableTreeWalker(ref.current); |
| 97 | if (focusMode === 'child') { |
| 98 | // If focus is already on a focusable child within the cell, early return so we don't shift focus |
| 99 | if (isFocusWithin(ref.current) && ref.current !== getActiveElement()) { |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | let focusable = |
| 104 | state.selectionManager.childFocusStrategy === 'last' |
| 105 | ? last(treeWalker) |
| 106 | : (treeWalker.firstChild() as FocusableElement); |
| 107 | if (focusable) { |
| 108 | focusSafely(focusable); |
| 109 | return; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | if ( |
| 114 | (keyWhenFocused.current != null && node.key !== keyWhenFocused.current) || |
| 115 | !isFocusWithin(ref.current) |
| 116 | ) { |
| 117 | focusSafely(ref.current); |
| 118 | } |
| 119 | } |
| 120 | }; |
| 121 | |
| 122 | let {itemProps, isPressed} = useSelectableItem({ |
| 123 | selectionManager: state.selectionManager, |
no test coverage detected