(e: ReactKeyboardEvent)
| 290 | }; |
| 291 | |
| 292 | let onKeyDown = (e: ReactKeyboardEvent) => { |
| 293 | let activeElement = getActiveElement(getOwnerDocument(ref.current)); |
| 294 | if ( |
| 295 | !nodeContains(e.currentTarget, getEventTarget(e) as Element) || |
| 296 | state.isKeyboardNavigationDisabled || |
| 297 | !ref.current || |
| 298 | !activeElement |
| 299 | ) { |
| 300 | return; |
| 301 | } |
| 302 | |
| 303 | if (keyboardNavigationBehavior === 'tab') { |
| 304 | if (getEventTarget(e) !== ref.current && e.key !== 'Tab') { |
| 305 | e.stopPropagation(); |
| 306 | return; |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | switch (e.key) { |
| 311 | case 'Tab': { |
| 312 | if (keyboardNavigationBehavior === 'tab') { |
| 313 | // If there is another focusable element within this item, stop propagation so the tab key |
| 314 | // is handled by the browser and not by useSelectableCollection (which would take us out of the list). |
| 315 | let walker = getFocusableTreeWalker(ref.current, {tabbable: true}); |
| 316 | walker.currentNode = activeElement; |
| 317 | let next = e.shiftKey ? walker.previousNode() : walker.nextNode(); |
| 318 | |
| 319 | if (next) { |
| 320 | e.stopPropagation(); |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | }; |
| 326 | |
| 327 | // Grid cells can have focusable elements inside them. In this case, focus should |
| 328 | // be marshalled to that element rather than focusing the cell itself. |
nothing calls this directly
no test coverage detected