Help and docs
Sign in

R62 feat: focus the element under a left click

Browse files
grindlemire 23d 14 files +582 ~41
Landed bygrindlemireas 9599fc12 · with 7 other reviews See in history

A left press now focuses the nearest element at or above the pointer that
is in the Tab order, the way a browser does, so clicking an or

lets you type in it. A click with no tab stop there leaves focus alone, and an open modal limits it to the modal's content; a modal that traps focus keeps clicks out the same way it keeps Tab out. The hover example's input now says click or Tab to focus. Clicks make focus jump around the tree far more than Tab did, which exposed that a re-render restored focus by its index in the focus list. Adding a focusable earlier in the tree, reordering keyed rows, or switching pages moved focus to whatever element now sat at that index, and an unmounted Input kept claiming keys. Focus is now found again by the component that rendered the element, plus its key path or its position among that component's focusables; when it is gone it gets its blur and nothing is focused. A keyed row whose container moved (a line appeared above the list) is still found by its keys. Modals restore focus the same way on close.