Skip to content

Overlay and navigation primitives on React Aria - #157

Merged
sgomez merged 5 commits into
frontend-rebuildfrom
agent/frontend/138
Nov 25, 2026
Merged

sgomez merged 5 commits into
frontend-rebuildfrom
agent/frontend/138

Conversation

@sgomez

@sgomez sgomez commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Closes #138. Part of #135.

Summary

The overlay and navigation primitives on react-aria-components:

design-system/
├── LinkRouter.tsx     # new: RAC RouterProvider over react-router's useNavigate/useHref
├── ConfirmDialog.tsx  # RAC Dialog (alertdialog, Heading, Text) inside the native modal <dialog>
├── Disclosure.tsx     # RAC Disclosure + Button slot="trigger" + DisclosurePanel (was <details>)
├── Tabs.tsx           # LinkTabs: <nav> of RAC Links with aria-current; Tabs: RAC Tabs/TabList/Tab/TabPanel
├── TextLink.tsx, Row.tsx, Button.tsx (LinkButton)
│                      # `to` → RAC Link (client navigation); `href` → plain <a> (an address outside the Console)
└── IdentityCard.tsx   # unchanged (#156 left one link, logout, outside the Console)
 <ConsoleRoutes> (app)
   <SessionPortContext>
+    <LinkRouter>
       <Console>

Storybook's decorator wraps every story in MemoryRouter + LinkRouter, so story links navigate client-side as in production.

console.css, same values as the selectors they replace:

-a:focus-visible,button:focus-visible,summary:focus-visible,
+a:focus-visible,button:focus-visible,[role=tab][data-focus-visible],
-.btn[disabled],.btn.is-disabled{…}
+.btn[disabled],.btn[data-disabled]{…}
-.grp>summary{list-style:none;cursor:pointer;…}         (+ ::before, [open], :hover, .empty)
+.grp>[slot=trigger]{width:100%;border:0;background:none;color:inherit;font:inherit;text-align:start;cursor:pointer;…}
-.tabs a.on / .tabs button / button:hover / button.on
+.tabs a[data-current] / .tabs [role=tab] / [data-hovered] / [data-selected]
+.dialog>[role=alertdialog]{display:flex;flex-direction:column;gap:12px}   (the gap .dialog already had)

The trigger's button reset reuses the values of .menu button.nav-item and .row; font:inherit is the one new keyword, so the button keeps the summary's 14px/1.5. .menu-pop was already gone (the tracer moved it to Popover props).

Stories with play functions (axe on every story):

Story file Stories
ConfirmDialog Open (:modal, alertdialog named and described, Cancel focused), Delete ("Cancel"/"Delete"), Busy (pending verb, Cancel disabled, Escape ignored), Escape cancels and hands the focus back, The keyboard confirms, Cancel closes it
Disclosure Folded, Card, Keyboard (Enter opens, Space closes, aria-controls)
Tabs Links (aria-current, Tab between links, Enter navigates), Draft: Panels (ArrowRight/ArrowLeft wrap, selection follows focus, Tab to the panel)
Links Route (Enter navigates client-side), Inherit, Address (plain <a>), Linked row
IdentityCard Signed in, A long identity is cut
Button Links: disabled LinkButton is <span role=link aria-disabled data-disabled> at opacity .5

jsdom tests of these primitives moved into the stories (ConfirmDialog.test.tsx removed; the Tabs, Disclosure, TextLink, Row and IdentityCard blocks removed from the shared test files). Call-site tests updated for the new markup: StatePages, PublishProblems, ServiceProvidersPager.

Evidence

Before: row, text and button links were react-router Links and button tabs had no tab semantics; the dialog had no alertdialog role; the disclosure was <details>.
After: production build under core's CSP, with the tracer's method (PR #154): vite build served by php -S with a router that sends SimpleSAML\Configuration::DEFAULT_SECURITY_HEADERS from vendor/ and the markup of templates/app.twig, API answered from fixtures, Playwright Chromium 1.65.1 with real key presses, listening for securitypolicyviolation, console errors and page errors, and listing <style> elements.

Content-Security-Policy: default-src 'none'; frame-ancestors 'self'; object-src 'none'; script-src 'self'; style-src 'self'; font-src 'self'; connect-src 'self'; media-src data:; img-src 'self' data:; base-uri 'none'

list 1440:    Button "Delete…" opened ConfirmDialog (RAC Dialog, Heading, Text in the native <dialog>),
              focus on Cancel, Tab to Delete, real Escape closed it, focus back on "Delete…"
list 1440:    reopened, "Cancel" closed it
list 1440:    linked Row (RAC Link under RouterProvider) has the basename in its href and navigated client-side to edit
list 1440:    LinkButton "Add" (RAC Link) navigated client-side
publish 1440: Disclosure "2 warnings" (card) opened
publish 1440: TextLink in the warnings (RAC Link) navigated client-side
edit 1440:    Menu "Delete…" opened the dialog, Escape closed it, focus back on "More actions"
violations: []   consoleErrors: []   pageErrors: []   styleElements: []

state page 1440 (API answers 503 Unreachable):
              Disclosure "Technical detail" (RAC Disclosure, DisclosurePanel) opened with Enter, closed with Space
violations: []   pageErrors: []   styleElements: []   consoleErrors: the expected 503 only

"Client-side" means a flag set on window after the first load survived the navigation. Control run, same build, stylesheet link without id="react-aria-pressable-style": style-src-elem "inline" violation and react-aria-pressable-style listed, so the listener is live.

Collapsed card disclosure, measured in the same build: group 51 px high, as the <details> was (49 px trigger + border).

Page screenshots: unchanged. npm run test:visual three times on the pushed head: Tests 56 passed (56) ×3, no reference touched.

Checks, run locally on the pushed head:

Check Result
composer test 605 passed
composer static stan, cs, size ok
npm run lint 0 problems
npm run typecheck ok
npm test 418 passed (jsdom + stories in Chromium); lines 99.35 %
npm run test:visual 56 passed, ×3
composer build no diff against the committed public/assets/app/

Departures

  • href links stay native <a>. Under RouterProvider, React Aria client-navigates every same-origin link through react-router, which would prefix core's pages (logout, #line-N) with the Console's basename. to (a Console route) goes through RAC Link; href (any other address) is a plain <a>. IdentityCard's logout is one of these, so IdentityCard has stories but no React Aria.
  • Panel tabs (Tabs with TabPanels) have no board and no caller yet: story Draft: Panels. The board's tabs are links (LinkTabs). API change: the old Tabs with per-tab to or onSelect is split into LinkTabs and Tabs({ tabs: {key, label, panel}[], selected, onSelect }). No call site used either.
  • ConfirmDialog focus. The native <dialog> focuses its first focusable descendant, which is now React Aria's tabindex=-1 container; the dialog moves the focus to Cancel after showModal(), as before.
  • Escape is handled on keydown as well as on cancel. Storybook's userEvent sends synthetic events, which do not raise the native close request, and the play functions must exercise Escape; real Escape goes through the same handler (the CSP run above uses real key presses). cancel remains for close requests without a key, such as a back gesture.
  • Busy confirm is pending (isPending), not disabled, so it keeps the focus; Cancel is still disabled while busy.
  • Disclosure panel: .grp-body sits on a div inside DisclosurePanel, not on the panel. The panel is hidden="until-found" (content-visibility), and padding on it would leave 16 px under a closed card.

Merge Danger

Door: two-way

Front end only. Revertable.

Blast Radius: front-end

  • Every RAC Link now navigates through LinkRouter; a page rendered without it (outside ConsoleRoutes or the Storybook decorator) would make full loads.
  • Tabs API split (no callers). Disabled LinkButton is a <span>, styled through [data-disabled].
  • Bundle main-*.js 461 kB (Disclosure, Dialog, Tabs from React Aria).

@sgomez
sgomez merged commit 239d7c1 into frontend-rebuild Nov 25, 2026
16 checks passed
@sgomez
sgomez deleted the agent/frontend/138 branch November 25, 2026 19:04
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.

1 participant