Skip to content

feat(ou-tree): keyboard, focus and ARIA: one tab stop, treeview keys, inner focus, searchbox - #1792

Open
HendrikThePendric wants to merge 20 commits into
feat/paged-org-unit-treefrom
feat/ou-tree-keyboard-focus
Open

HendrikThePendric wants to merge 20 commits into
feat/paged-org-unit-treefrom
feat/ou-tree-keyboard-focus

Conversation

@HendrikThePendric

@HendrikThePendric HendrikThePendric commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Implements DHIS2-21263 (client side, batch 5 of OuTree). Base: feat/paged-org-unit-tree, after batch 4 (#1787).


Description

OuTree is operable from the keyboard and correct for assistive technology. Still over the stand-in, still not exported.

  • One tab stop. The container holds DOM focus and names the focused row with aria-activedescendant, since rows scroll out of the DOM under virtualisation. Tab lands on the first visible row; the focused row shows the ring, the container none.
  • Treeview keys. Up, Down, Home and End move; Right opens a node or steps into it; Left closes a node or steps out to its parent; Enter toggles (and so retries a failed node). Space is reserved for selection. No type-ahead: a paged tree does not know the names it has not loaded.
  • Inner focus. Shift+Enter moves focus into the row's first control (the eye, a retry); Tab cycles the row's controls; Escape returns to the tree. The buttons are out of the Tab order (tabIndex=-1) and rows with a control say aria-keyshortcuts="Shift+Enter". Precedent: the W3C grid and treegrid patterns.
  • Focus is tree state. focusedKey with its last index as the fallback (a skeleton that became a node keeps the position), hasFocus set by the glue, the moves focusNext/focusPrevious/focusFirst/focusLast/focusParent/focusChild returning the new index so the list scrolls to it. The eye shows on the focused row as well as the hovered one. Hooks: useOuTreeNode adds isFocused; new useOuTreeRowFocused, useOuTreeRowElementId, useOuTreeFocusTarget, useOuTreeRegisterFocusTarget; useOuTreeKeyboard in the list.
  • Every row is a treeitem, with an element id from the provider's treeId (unique per tree on the page): skeleton rows busy and labelled "Loading", error rows labelled by their retry. The row shell takes the click, so the label and the toggle are plain spans; a click on a button inside the row does not toggle it. This resolves the Sonar accessibility findings from batch 4.
  • Search input. role="searchbox" (needs InputField to forward role: one prop added in @dhis2-ui/input), Down moves focus to the tree, Escape clears the search.
  • Guide lines light up as branches, as in the old tree. Hover an indent segment or an open node's toggle and the whole branch lights up (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.
  • Node rows shrink to kind, id, depth and view; the row component reads the rest through useOuTreeNode, and row reuse is key, depth and view.

Left for later: selection (next batch; it decides between Space on the row and a checkbox as an inner control), aria-setsize/aria-posinset (a paged list does not know them), the roots rows' retry while the roots failed, which stays in the Tab order as it is not a tree row.


Known issues

  • aria-activedescendant names a row that may not be rendered yet right after a long jump; the virtualiser scrolls it into the DOM in the same tick.
  • eslint's React Compiler warning on useVirtualizer remains, as in batch 3.

Checklist

  • API docs are generated (nothing is exported, so there is nothing to document)
  • Tests were added
  • Storybook demos were added (the key map in the OuTree description)

Screenshots

The Search story over the PAHO stand-in, searching clin: 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

HendrikThePendric and others added 14 commits November 17, 2026 18:07
…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
HendrikThePendric requested a review from a team as a code owner November 18, 2026 08:11
@HendrikThePendric
HendrikThePendric changed the base branch from master to feat/paged-org-unit-tree November 18, 2026 08:12
HendrikThePendric and others added 6 commits November 18, 2026 09:23
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>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 New issues
B Reliability Rating on New Code (required ≥ A)
1 New Code Smells (required ≤ 0)
1 New Bugs (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@dhis2-bot

Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-1792--dhis2-ui.netlify.app

This branch was successfully deployed

1 active deployment
netlify — 1bbb0d07 Deployed Nov 18, 2026 by dhis2-bot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants