Repository navigation
Port the Base UI list-navigation and typeahead infrastructure (Phase 3e) - #308
Merged
Merged
Conversation
First piece of Phase 3e (list navigation + typeahead), which lands together with the Menu family so the navigation infrastructure has a real consumer rather than sitting untested. TimeoutManager holds several keyed timeouts behind one handle, so a caller can start, replace and cancel each independently and drop them all on teardown. It is distinct from `utils/useTimeout`'s `Timeout`, which owns exactly one. Pure, so it is a straight transcription with no renderer adaptation. No consumer yet — Menu's typeahead and submenu timing are what use it. Untested on purpose rather than by omission: a differential test needs a rendered component, and the first one arrives with Menu. Co-Authored-By: Claude Opus 5 <[email protected]>
…gleClickHandler Three more Phase 3e helpers, landing with the Menu family so the navigation infrastructure has real consumers rather than sitting untested. RequestQueue tracks each key's lifecycle through queued -> pending and caps in-flight requests, with `pickEntries` as the subclass hook for ordering (FIFO by default). getPseudoElementBounds widens an element's box to cover its ::before/::after, so hit-testing accounts for decorations drawn outside it; it short-circuits under jsdom, where getComputedStyle with a pseudo-element is not implemented. Both are pure, so they are straight transcriptions. useMixedToggleClickHandler is a hook, so it follows the binding's plain-`.ts` convention: the caller's slot arrives as the trailing argument via `splitSlot` and the `useRef`/`useMemo` it composes take derived sub-slots. Its events are native rather than synthetic, so the handlers take the native event and `preventBaseUIHandler` is the shim `mergeProps` attaches. Upstream's empty `UseMixedToggleClickHandlerState` interface is a docs-pipeline artifact with no members and is dropped. No consumers yet — Menu's trigger and submenu behavior are what use these. Untested on purpose rather than by omission: a differential test needs a rendered component, and the first one arrives with Menu. Validation: `tsrx-tsc --noEmit` on @octanejs/base-ui and `pnpm format:check`, both clean. No test run — these files have no consumer and no test yet. Co-Authored-By: Claude Opus 5 <[email protected]>
The largest piece of Phase 3e (list navigation + typeahead), which lands together
with the Menu family so the navigation infrastructure has a real consumer rather
than sitting untested.
useListNavigation adds arrow-key navigation over a list of items using either real
DOM focus or virtual focus (`aria-activedescendant`), and returns the
`{ reference, floating, item, trigger }` prop bags Menu, Select and Combobox merge
onto their parts. octane adaptations: it reads the FloatingRootStore
(`store.useState`/`select`/`setOpen`/`context`); events are native, so
`event.nativeEvent` collapses to `event`; `useIsoLayoutEffect` is octane's
`useLayoutEffect`, and because a plain-`.ts` hook is not compiled, an `undefined`
dep array runs the effect every render, matching upstream's dep-less form; every
composed hook threads an explicit sub-slot. The two dev-only `console.warn`
misconfiguration guards are dropped — this package carries no
`process.env.NODE_ENV` branches.
The `grid` option stays injected rather than imported, so non-grid consumers keep
the grid helpers out of their bundles. It is typed here as `GridNavigator`, which
the `gridNavigation` port satisfies structurally.
Porting this exposed that the vendored list-navigation helpers had drifted from
Base UI 1.6.0: `isListIndexDisabled` neither skipped invisible items nor kept the
attribute fallback separate from an explicit `disabledIndices`. useListNavigation
depends on that separation — it deliberately omits `disabledIndices` when choosing
the item to focus on open so attribute-disabled items are still skipped for
consumers passing an empty array (mui/base-ui#2604). `list-utils` now matches
upstream's body and signatures, and `useCompositeRoot` drops the `{ current }`
wrappers it needed for the old shape. That is a behavior fix for the already
shipped composite roving focus, so it carries a changeset.
No consumer yet — Menu is what uses this. Untested on purpose rather than by
omission: a differential test needs a rendered component, and the first one arrives
with Menu.
Validation: `tsrx-tsc --noEmit` clean, `vitest --project base-ui` 96/96 green,
prettier clean on the changed files.
Co-Authored-By: Claude Opus 5 <[email protected]>
Ports three Base UI 1.6.0 sources for the list-navigation infrastructure: - `floating-ui-react/hooks/gridNavigation.ts` -> `utils/floating/gridNavigation.ts`, the uniform 1x1 navigator `useListNavigation` injects for its own `grid` option. - `internals/composite/root/gridNavigation.ts` -> `utils/composite/gridNavigation.ts`, the cell-map-backed navigator a composite passes to `useCompositeRoot`'s `grid` prop. Two different upstream files, kept separate. - `floating-ui-react/hooks/useTypeahead.ts` -> `utils/floating/useTypeahead.ts`, native-event and slot-threaded like the other floating hooks. Both navigators need the grid half of upstream's `floating-ui-react/utils/composite.ts` (`getGridNavigatedIndex` and the cell-map helpers), which had no counterpart here; it lands as `utils/composite/grid-utils.ts`, beside the list algebra this binding already vendors into `list-utils.ts`. It depends on that module's Base UI 1.6.0 signatures, which arrive with `useListNavigation`. No consumer until Menu lands, so no tests yet. Co-Authored-By: Claude Opus 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 tasks done
trueadm
added a commit
that referenced
this pull request
Jul 27, 2026
… stage 1) (#316) * feat(base-ui): port the Menu open/close + roving-focus path (Phase 3f stage 1) `@octanejs/base-ui/menu` now exposes `Menu.Root`, `Menu.Trigger`, `Menu.Portal`, `Menu.Positioner`, `Menu.Popup`, `Menu.createHandle` and `Menu.Handle`, ported from `@base-ui/react` 1.6.0's `menu/store`, `menu/root`, `menu/trigger`, `menu/portal`, `menu/positioner` and `menu/popup`. This is the first CONSUMER of the Phase 3e list-navigation infrastructure, which merged (#308) deliberately untested because a differential test needs a rendered component. `MenuRoot` wires `useListNavigation` + `useTypeahead` to the popup store and `Menu.Positioner` wraps the popup in the `CompositeList` that feeds their element/label refs. 3e needed no repairs. Supporting additions: `useOpenInteractionType` (only the stateless `useOpenMethodTriggerProps` half had been ported, since Popover keeps `openMethod` in its store), `DROPDOWN_COLLISION_AVOIDANCE` / `TYPEAHEAD_RESET_MS` / `PATIENT_CLICK_THRESHOLD` in `utils/constants` (Popover's local copy of the last one now imports it), `findRootOwnerId`, and the `cancel-open` / `sibling-open` change reasons. `MenubarContext` and `ContextMenuRootContext` land as context-only modules ahead of their components (stage 4), so Menu's ~dozen `parent`-union branches are transcribed verbatim rather than stubbed and re-threaded later. Nothing provides them yet, so those branches are inert. Tests: 5 differential fixtures (closed trigger; open modal, non-modal, explicit placement, and disabled roots) plus 6 behavior tests for what the rig cannot see — click toggle, arrow-key open, Escape dismiss, the ARIA contract, `aria-orientation` reaching the popup from `useListNavigation`, and focus entering the popup and returning to the trigger. A `Menu.Popup` takes focus on open and the rig mounts both runtimes in one jsdom document, so whichever popup is focused last makes the other runtime's portal see an outward `focusout` and run `disableFocusInside`, rewriting that portal's focus-guard `tabindex`. Both runtimes run identical code; the asymmetry is one `document.activeElement` for two apps. `parity.test.ts` normalises the guards' tabindex away for the open-menu fixtures and byte-compares everything else. Items, submenus, `Viewport`/`Arrow`/`Backdrop`/`Separator`, `Menubar` and `ContextMenu` land in stages 2-4. Co-Authored-By: Claude Opus 5 <[email protected]> * test(base-ui): cover Menu's detached-trigger and handle open/close path Review flagged `MenuRoot`'s floating root context as never installed on `MenuStore`. It is — `usePopupInteractionProps` syncs its whole state part, and `floatingRootContext` is in it, exactly as upstream `MenuRoot.tsx` does it. The real gap was coverage: nothing exercised the path that routes through `MenuStore.setOpen` → the context's event bus. A normal trigger click goes through `FloatingRootStore.setOpen` → `onOpenChange` instead, so it would not have caught a dead bus. Adds a `MenuWithHandle` fixture whose `Menu.Trigger` is a SIBLING of `Menu.Root`, associated only by a shared `MenuHandle`, and tests that open through the detached trigger, close through `handle.close()`, reopen through `handle.open(triggerId)` with the popup's `aria-labelledby` resolving to that trigger, and throw for an unregistered id. Negative control: deleting `floatingRootContext` from that state part fails six of the eight tests in `tests/menu.test.ts`. Also documents the install site — Menu cannot build its context in the store constructor the way Dialog/Popover do, because its store may be an external `MenuHandle` store shared with triggers outside the Root, so the context must be created by the Root that owns `setOpen` and published from there. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
This was referenced Oct 1, 2026
This branch was previously 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.
Summary
@octanejs/base-ui, transcribed from Base UI 1.6.0.Why
3e is pure infrastructure with no consumer until Menu/Select/Combobox exist. Landing it alone would leave the differential rig nothing to render and no behavior test exercising it — the same shape as the
openOnHoverstub that sat inert and unflagged for months. Hence: review now, merge with Menu.Changes
useListNavigation(930 loc upstream) — arrow-key navigation over a list using either real DOM focus or virtual focus (aria-activedescendant), returning the{ reference, floating, item, trigger }bags Menu, Select and Combobox merge onto their parts. octane adaptations: reads theFloatingRootStore(store.useState/select/setOpen/context); events are native, soevent.nativeEventcollapses toevent;useIsoLayoutEffectis octane'suseLayoutEffect, and because a plain-.tshook is not compiled, anundefineddep array runs the effect every render, matching upstream's dep-less form; every composed hook threads an explicit sub-slot. The two dev-onlyconsole.warnmisconfiguration guards are dropped — this package carries noprocess.env.NODE_ENVbranches.Grid navigation —
utils/composite/grid-utils.tsholds the two-dimensional algorithm and the cell-map helpers, with the twogridNavigationentry points beside their consumers:utils/floating/gridNavigation.ts(the uniform 1x1 navigatoruseListNavigationinjects into its owngridoption) andutils/composite/gridNavigation.ts(the navigator a composite passes touseCompositeRoot).gridstays injected rather than imported, so a consumer that never passes it leaves the grid helpers out of its bundle entirely — that is the point of the injection.useListNavigationtypes the option asGridNavigator, whichgridNavigationsatisfies structurally.useTypeahead— matches list items as the user types, the way a native<select>does; pairs withuseListNavigation.Supporting utilities —
TimeoutManager(several keyed timeouts behind one handle, distinct fromuseTimeout's single-timeoutTimeout),RequestQueue,getPseudoElementBounds,useMixedToggleClickHandler.Upstream-drift fix (behavioral). Porting
useListNavigationexposed that the vendored list-navigation helpers inutils/composite/list-utils.tshad drifted from Base UI 1.6.0:isListIndexDisabledneither skipped invisible items nor kept thedisabled/aria-disabledattribute fallback separate from an explicitdisabledIndices.useListNavigationdepends on that separation — it deliberately omitsdisabledIndiceswhen choosing the item to focus on open so attribute-disabled items are still skipped for consumers passing an empty array (mui/base-ui#2604).list-utilsnow matches upstream's body and signatures (item array for the index helpers, ref forgetMinListIndex/getMaxListIndex), anduseCompositeRootdrops the{ current }wrappers it needed for the old shape. This changes the already-shipped composite roving focus — hidden items are now skipped — so it carries a patch changeset.REASONS.listNavigationwas added alongside.Validation
pnpm format:checkpnpm typecheckpnpm test— 13,937 tests / 1,399 files, all passingRisk / follow-ups
isListIndexDisabledfidelity fix above; it is covered by the existing composite suite and carries a changeset.useClientPointalready ported) are cheap.🤖 Generated with Claude Code
Note
Medium Risk
Large, accessibility-critical keyboard/focus surface with a behavioral change to existing composite navigation; risk is moderated because it tracks upstream 1.6.0 and has no Menu/Select consumer wired in this PR alone.
Overview
Phase 3e brings Base UI’s floating list infrastructure into
@octanejs/base-ui:useListNavigation(arrow keys, real or virtual focus viaaria-activedescendant,{ reference, floating, item, trigger }prop bags) anduseTypeahead(type-to-match, meant to pair with list navigation). Grid support is opt-in via injection—grid-utilsplus separategridNavigationfactories foruseCompositeRoot(multi-cell grids) anduseListNavigation(uniform 1×1 grids)—so Menu/Select-style consumers can tree-shake the heavy grid code.Also adds small upstream utilities:
RequestQueue,TimeoutManager,getPseudoElementBounds,useMixedToggleClickHandler, andREASONS.listNavigationfor open/close details.Shipped behavior change: vendored
list-utilsnow matches Base UI 1.6.0’sisListIndexDisabled(explicitdisabledIndiceswins; invisible items always skipped;disabled/aria-disabledonly when nodisabledIndiceswas passed).useCompositeRootcall sites were updated for array-based helpers—composite roving focus now skips non-visible items (patch changeset).Reviewed by Cursor Bugbot for commit 90b44ae. Bugbot is set up for automated code reviews on this repo. Configure here.