Repository navigation
feat(ou-tree): keyboard, focus and ARIA: one tab stop, treeview keys, inner focus, searchbox - #1792
Open
HendrikThePendric wants to merge 49 commits into
Open
HendrikThePendric wants to merge 49 commits into
HendrikThePendric wants to merge 49 commits into
Conversation
…iew moves A row key with its last index as the fallback, hasFocus set by the glue, isFocused for rows, and focusNext/Previous/First/Last/Parent/Child returning the new index. Every row is indexed by its key now. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… one Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… the provider aria-activedescendant needs element ids unique per tree on the page, and the search input needs a way to hand focus to the list's container. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…he click Every row is a treeitem now, skeleton rows busy and labelled, error rows labelled by their retry, each with an element id for aria-activedescendant and the focus ring while focused. The row shell takes the click, so the label and the toggle are plain spans; the eye and the retry buttons leave the tab order, reached by the row's inner focus. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…s for a row's controls The container is the tree's one tab stop and names the focused row with aria-activedescendant; the arrows, Home and End move it, Right and Left open, close and step between levels, Enter toggles. Shift+Enter moves DOM focus into the row's first control, Tab cycles the row's controls and Escape returns to the tree. Moves scroll the row into view. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Input already renders one; InputField did not pass it through, so an InputField could not be a searchbox. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…and Escape clears Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ads the rest from the tree The children status and the result flag came off the store and the search through the row; the row component already read them through useOuTreeNode. Row reuse is now key, depth and view. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e it was focused Rows inserted above a focused row moved it; when its key then went, the fallback index pointed at an unrelated row far above. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Only the toggle is skipped for a click that was a button's, so the eye and the retry keep mouse and keyboard on the same row. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
With no rows, while the roots load or failed or a search has no results, the tab stop was invisible. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ght return from a control Tab cycles only within a row entered from the tree (its controls have tabIndex -1), so the roots retry, which is in the tab order, is left as usual. Left and Right pressed inside a control return to the tree and act. A move key without a focused row starts at the first visible row. Enter on a row that is not a node clicks its control, the retry. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… and closes it on click The old tree's line was the ancestor's toggle, spanning its subtree: hovering it lit the branch and clicking it collapsed the ancestor. The flat list draws a segment per row, so a guide is tree state now: the segment's ancestor and subtree are resolved once per change, each row reads its lit level, and a click on a lit segment closes the branch and focuses the ancestor. The focused row's parent branch is lit while the tree has focus, so the keyboard shows the branch too. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
HendrikThePendric
changed the base branch from
master
to
feat/paged-org-unit-tree
November 18, 2026 08:12
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…the label Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A literal tabIndex is what the activedescendant lint rule reads. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tion exists Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ol and the row's Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
|
🚀 Deployed on https://pr-1792--dhis2-ui.netlify.app |
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ntainer takes the click A row's actions are its controls: the arrow joins the eye and the retries as a button out of the tab order, named Expand or Collapse. The label is a plain span until selection gives it something to do, and a click on a row or its label only focuses the row. The row shell takes no click: the container does, focusing the tree when focus was elsewhere and the row the click landed in, by the virtual row's index. The controls leave DOM focus on the tree: the mouse does not focus them, and Enter or Space on an entered control acts on it from the tree, so a control that goes away, like the arrow behind the loader, does not take focus with it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ntrol The container refocused itself only when DOM focus was outside the tree, so a click on a control while focus sat in another row's entered control left the keys acting on that stale control. The container now focuses itself whenever it is not the active element, after focusing the clicked row, and the focus handler reads the focused row live (getFocusedIndex on the actions) rather than from the last render. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…r the pointer An element removed under the pointer fires no pointerleave, so the arrow clicked behind the loader left the node's guide lit until the pointer crossed another guide, and a hovered row or segment scrolled out of the virtual range left its hover state behind. useHoverReport tracks what is under the pointer and reports the leave from its cleanup; the toggle and the row shell, for the row and its segments, use it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…n the tree is focused aria-activedescendant named a row the virtualiser had dropped once it scrolled out of the range, so after a wheel scroll Enter and Shift+Enter found no element and did nothing, assistive technology saw a tree with no item, and a long jump named the row a frame before it existed. The virtualiser's rangeExtractor now keeps the focused row in the rendered range wherever the viewport is, and the pages are requested for the viewport and its overscan, not for the pinned row. Focus arriving on the container scrolls the focused row into view, as the aria-activedescendant practice asks. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The tree view pattern requires a name on the element with role tree, and the container had none, so a screen reader announced an unnamed tree. The list and OuTree take ariaLabel, "Organisation units" unless given, or ariaLabelledBy for a visible element that names the tree. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… it could not load A treeitem without a label of its own is named from its content, which takes in the arrow button's name, so browsers announced rows as "Collapse Zambia" and, focused in search mode, with the eye's name too. A failed node was indistinguishable from a closed one: its retry button was named by the label it wraps. The label slot is now an element, OuTreeLabelSlot, with no box of its own, and the row's aria-labelledby names it, with renderLabel content included; the retry button is named "Could not load children. Retry" and the failed row's aria-describedby names the button. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…reeRowFocused The same subscription was written out twice. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The three rows each built the same two closures over the row key for the shell's guide hover and click. The hook, which already has the key and the tree, returns them, stable. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…lled The click focuses a row by its index through focusRow; setFocused by key stays on the tree state, for tests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…the pinned focused row Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… of aria-setsize Browse mode has the count once a parent's first page arrived, the slots; search mode counts the matching children, -1 until every result arrived, as ARIA allows for a set of unknown size. Result placeholders carry no place. The row carries both numbers, and row reuse compares them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…then out of the tree Past the last control, or before the first with Shift, the container is focused and the browser's Tab goes on from it, out of the tree, as the controls are not in the tab order. Tab no longer cycles within the row: leaving the widget is what Tab does on a page, and rows are reached with the arrow keys. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The clearable input's clear button had no accessible name: an icon only. It is now labelled "Clear", through the package's locales like the other icon buttons. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The element every row sits in wraps a row's content as the tree container wraps the rows: one word for one job, at two levels. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The keyboard hook found a row's controls by what was focusable and told "entered from the tree" from "in the page's tab order" by the tab index. Now a control is marked: rowControlProps carries data-ou-tree-control, tabIndex -1 and the mouse-down guard, the built-in controls spread it, and a custom label spreads it on a control of its own to be reached the same way, with Shift+Enter and Tab. The hook finds controls by the attribute, disabled ones excluded, and nothing unmarked is one. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…config Generated by yarn setup for the new components/input/i18n/en.pot; CI checks the committed file against the generated one. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…side the row's The arrow, the eye and the retry buttons had only the browser's default focus outline, which read as a second border on the row. Each now has a focus style separate from its hover: an inset ring in the focus blue. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… entered one Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ls is entered Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…nd focuses it in turn Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…wControl The arrow, the eye and the retry buttons spread the hook's props; the rows provide their key to it. The roots' retry stays a plain tab stop outside any row. The keyboard hook finds controls by their tab index until the tree state hands them over. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…cus follows Shift+Enter enters the focused row's first control, Tab and Shift+Tab move along them in DOM order and past the ends leave the tree, Escape leaves the row, Enter and Space act on the control, which keeps focus. A control that goes away hands focus back to the container through its unregistration, as an effect, not a timer. A click inside the entered control keeps it entered; any other click focuses its row and the tree. The keyboard hook no longer queries the DOM for controls. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…s it Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ee ends inner focus The container took focus from a tabbable retry, or a control, that focus reached from outside the tree: the recovery effect now acts only when focus left the container, as it does when the entered control went away, and a key that leaves the row focuses the container itself. A control entered when the tree lost focus stayed entered, so Shift+Enter on return did nothing: losing the tree's focus now ends inner focus, and focus arriving on a control from outside the keys enters it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…r focused, not by state The eye sits in the row of every open node with matching children, marked data-hover-only, which the row container shows while hovered or focused. setHovered, isHovered and the row's hover report go; useHoverReport stays for the guide segments and the toggle. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The controls register with a row since they took useOuTreeRowControl, so the stories that show them alone give them one. The eye's caption says the row shows it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ick shows none The glue tracks whether focus is the keyboard's (focusVisible in the tree state): a key makes it so, a pointer down or the click hook's focus makes it the pointer's, and the ring, the eye on focus and the lit parent branch follow. Focus arriving by Tab counts as the keyboard's. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Implements DHIS2-21263 (client side, batch 5 of
OuTree). Base:feat/paged-org-unit-tree, after batch 4 (#1787).Description
OuTreeis operable from the keyboard and correct for assistive technology. Still over the stand-in, still not exported. This resolves the Sonar accessibility findings from batch 4 and keeps the row container clear of the new ones.Principles
aria-activedescendant. Rows scroll out of the DOM under virtualisation, so they cannot hold focus themselves; the active row is kept in the rendered range wherever the viewport is, so the name always resolves. The active row shows the focus ring, the container none, and only for keyboard focus: a click focuses the row it lands in without a ring, as a button does.useOuTreeRowControl(exported) and spreads its props: the built-in ones do, and a custom label's control does the same to be reached the same way; nothing else in a row is one.ariaLabel, "Organisation units" unless given, orariaLabelledBy). A node row is named by its label alone, so the arrow's and the eye's names stay out of it; a failed node is described by its retry; skeleton rows are busy and say "Loading". Every row under a parent says its place among the siblings (aria-posinsetofaria-setsize), from the slot count in browse mode and the matching children in search mode,-1until every result arrived. Every row isaria-selected="false"until selection exists.Keyboard
With the tree focused:
useOuTreeRowControl. Rows with a control announce it asaria-keyshortcuts.Inside a row's controls, after Shift+Enter:
In the search input:
The mouse does not focus a row's controls (a click keeps focus on the tree), and the roots' retry while the roots failed stays in the Tab order, as it is not a tree row.
Implementation notes
focusedKeywith its last index as the fallback,hasFocusandfocusVisibleset by the glue (a key makes focus the keyboard's, a pointer makes it the pointer's, which shows no ring), the movesfocusNext/focusPrevious/focusFirst/focusLast/focusParent/focusChildreturning the new index so the list scrolls to it, and the focused row pinned into the virtualiser's range (rangeExtractor) and scrolled into view when focus arrives on the container. The eye sits in the row of every open node with matching children and is shown in CSS while the row is hovered or focused; row hover is not state. Hooks:useOuTreeNodeaddsisFocused; newuseOuTreeRowFocused,useOuTreeRowElementId,useOuTreeFocusTarget,useOuTreeRegisterFocusTarget;useOuTreeKeyboardin the list.treeitemwith an element id from the provider'streeId(unique per tree on the page). A node row is named by its label slot (aria-labelledby); a failed node's retry button is named "Could not load children. Retry" and is the row'saria-describedby. The row's controls register throughuseOuTreeRowControl, which hands backtabIndex=-1, the mouse-down guard and a ref; the registry (tree/row-controls.ts) reads a row's controls in DOM order when a move asks, disabled ones excluded, because controls mount late (the eye on focus, the arrow after the loader). An entered control focuses itself in an effect, and enters itself when focus arrives on it some other way; a key that leaves the row focuses the container at once; the container takes focus back in an effect when the entered control went away, since a removed element drops focus on the page body without a blur. Losing the tree's focus ends inner focus. Past the last control, Tab focuses the container and the browser's Tab goes on from there.posInSet/setSize; the row component reads the rest throughuseOuTreeNode, and row reuse compares key, depth, view and place.role="searchbox"(needsInputFieldto forwardrole: one prop added in@dhis2-ui/input, whose clear button also gets its name, "Clear", on the way).grey500), click it to close the branch and focus its ancestor; the keyboard gets there with Left repeated. The focused row's parent branch is lit while the tree has focus, so arrowing through a deep branch shows which one you are in. A hover is reported left when its element unmounts under the pointer (useHoverReport), the arrow behind the loader included, so no branch stays lit.Left for later: selection (next batch; the label becomes a control that selects, and it decides between Space on the row and a checkbox as an inner control).
Known issues
useVirtualizerremains, as in batch 3.Checklist
OuTreedescription)Screenshots
The
Searchstory over the PAHO stand-in, searchingclin: Catamarca focused from the keyboard with its eye; focus moved into the eye with Shift+Enter; End scrolled to the last row; a branch lit from its guide line.🤖 Generated with Claude Code