(e: ReactKeyboardEvent)
| 273 | }; |
| 274 | |
| 275 | let onKeyDown = (e: ReactKeyboardEvent) => { |
| 276 | let activeElement = getActiveElement(getOwnerDocument(ref.current)); |
| 277 | if ( |
| 278 | !nodeContains(e.currentTarget, getEventTarget(e) as Element) || |
| 279 | state.isKeyboardNavigationDisabled || |
| 280 | !ref.current || |
| 281 | !activeElement |
| 282 | ) { |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | if (keyboardNavigationBehavior === 'tab') { |
| 287 | if (getEventTarget(e) !== ref.current && e.key !== 'Tab') { |
| 288 | e.stopPropagation(); |
| 289 | return; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | switch (e.key) { |
| 294 | case 'Tab': { |
| 295 | if (keyboardNavigationBehavior === 'tab') { |
| 296 | // If there is another focusable element within this item, stop propagation so the tab key |
| 297 | // is handled by the browser and not by useSelectableCollection (which would take us out of the list). |
| 298 | let walker = getFocusableTreeWalker(ref.current, {tabbable: true}); |
| 299 | walker.currentNode = activeElement; |
| 300 | let next = e.shiftKey ? walker.previousNode() : walker.nextNode(); |
| 301 | |
| 302 | if (next) { |
| 303 | e.stopPropagation(); |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | }; |
| 309 | |
| 310 | // Grid cells can have focusable elements inside them. In this case, focus should |
| 311 | // be marshalled to that element rather than focusing the cell itself. |
nothing calls this directly
no test coverage detected