Repository navigation
Conversation
commit: |
Bundle size reportTotal Size Change: ▼-86B(-0.01%) - Total Gzip Change: 🔺+3B(0.00%) Show details for 69 more bundles@base-ui-components/react/context-menu parsed: ▼-22B(-0.02%) gzip: 🔺+3B(+0.01%) |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Bundle size report
|
atomiks
left a comment
There was a problem hiding this comment.
Change looks solid, though I wonder what happens with Select's positioning if the disabled item is currently selected given it overlaps the trigger?
@atomiks if the selected item is first and disabled it focuses it. Otherwise it finds the first non-disabled item if no item is preselected. I think this behavior makes sense. Here is a sandbox to test the behavior: https://codesandbox.io/p/devbox/wizardly-shannon-dq8svg?file=%2Fsrc%2FApp.tsx&workspaceId=ws_HE9JRzFW36Y2kpBoSwdvZ5 |
Remove the vestigial previousOnNavigateRef (onNavigate is a stable callback, so it always stored the same reference) and the stale comment describing the removed conditional-onNavigate behavior. Resolve the owner document from the in-DOM domReferenceElement instead of the provably-null floatingElement (realm-safe). Document the deliberate disabledIndices omission in initial focus (regression guard for mui#2604).
Remove the vestigial previousOnNavigateRef (onNavigate is a stable callback, so it always stored the same reference) and the stale comment describing the removed conditional-onNavigate behavior. Resolve the owner document from the in-DOM domReferenceElement instead of the provably-null floatingElement (realm-safe). Document the deliberate disabledIndices omission in initial focus (regression guard for mui#2604).
…3e) (#308) * feat(base-ui): port TimeoutManager 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]> * feat(base-ui): port RequestQueue, getPseudoElementBounds, useMixedToggleClickHandler 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]> * feat(base-ui): port useListNavigation 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]> * feat(base-ui): port grid navigation and useTypeahead 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]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
Opening a virtualized list with an arrow key scanned only the DOM for the first enabled item, so the first unmounted slot was picked as enabled and `isItemDisabled` was ignored. The initial-open scan now consults the consumer predicate alongside the DOM state, keeping the attribute-based skipping that mui#2604 relies on. A disabled `<Combobox.Virtualizer>` stayed registered with the list, which suppressed the DOM `scrollIntoView` that static lists rely on while the virtualizer itself scrolled no rows. The registry entry now carries whether virtualization is enabled, and DOM scrolling is only suppressed while it is. Also list `Combobox.Virtualizer` in the anatomy. Co-Authored-By: Claude Opus 5 <[email protected]>
…stNavigation (the indexRef truth mirror with the reactive activeIndex reconciliation, the focusItem scheduler over enqueueFocus + the animation-frame handle, the wait-for-list-populated microtask→rAF retry with the disabledIndices-omitted initial sync (mui#2604), the per-effect previous-open/mounted snapshots standing in for the shared refs the upstream no-deps effect writes, the keyboard modality mirrors, commonOnKeyDown's nested close key/Home/End/grid/main-axis matrix with allowEscape, the item bag's hover sync + stationary-WebKit guard + pointer-leave reset with focus-back, the floating bag's Shift+Tab close + pointer-modality tracker, the trigger bag's open-on-navigation and virtual-input checks, and the aria-activedescendant attribute riding a new lazily-resolved ElementHandlers::attributes bag) plus gridNavigation (the positional-arg shim with the 2-column default and the out-of-bounds→None sentinel) and utils/composite's grid half (findNonDisabledListIndex/getMin/MaxListIndex, the getGridNavigatedIndex matrix — DOM-row inference via closest('[role=row]'), the virtualized-gap uniform-grid walk, the vertical loop offset math, the horizontal row-clamp/loop arms with the rtl swap — and the createGridCellMap/getGridCellIndexOfCorner/getGridCellIndices cell-map trio) — REASONS.listNavigation/focusOut added, ElementHandlers gains onPointerMove/onPointerLeave slots; 27 host + 13 wasm tests mirroring the upstream suite (the 2x2 cell-map packing, the vertical loop offset math, the rtl clamp, opens/wraps/disabled-skip, hover+pointer-leave reset, virtualfocus bus, aria-activedescendant, Shift+Tab, nested close, openOnArrowKeyDown=false, the injected 2D grid) — 127 wasm + 114 host crate-wide, cargo test --workspace green
… Base UI Menu
Every menu runs on Base UI's menu parts: Dropdown (and everything built on it,
ActionMenu included) on `menu`, row ContextMenu on `context-menu`, and
TooltipHost's canvas context menu and click popover on a `menu` root positioned
at the pointer through a virtual anchor. One item set (NestedItem, NestedCheckbox,
NestedRadio, NestedSelect, NestedCheckboxTree, NestedMenu, NestedLabel,
NestedStatic, NestedSeparator) serves all of them; NestedParent and its provider
and hook are deprecated no-ops.
Where Base UI follows the WAI-ARIA menu pattern and Radix did not, the menus
follow it:
- Tab in an open Dropdown closes it and moves on.
- Escape in a submenu closes only that submenu.
- Every disabled entry is keyboard-reachable, aria-disabled and inert.
- A Dropdown neither hides the page from assistive technology nor traps focus.
Where Base UI's default is not an accessibility choice, the Radix behaviour
stays:
- No wrap-around at either end (loopFocus={false} on roots and submenus).
- Modal menus: scroll locked, a press outside only closes the menu.
- Row and canvas context menus keep Tab and Shift+Tab inside the open menu.
Base UI's list navigation closes a menu on Shift+Tab as a cancellable
focus-out, which these menus cancel.
- A keyboard open focuses the first entry even when it is disabled. Base UI
skips disabled entries on open (mui/base-ui#2604) while arrow keys reach them;
APG places focus on the first item and keeps disabled items focusable.
- A ContextMenu opens to the right of the press point.
- A press in the notifications region does not dismiss a menu, and an open
menu receives Escape before a toast.
- Triggers, popups and check items keep their data-state values.
Supporting changes:
- An Escape a disabled entry's reason tooltip dismissed does not also close the
menu. Tooltip marks the Escape events it consumes; defaultPrevented cannot be
the signal, because Base UI prevents the default of every key but Tab on a
focused disabled item.
- Tooltip notes a press on a disabled trigger in the capture phase: Base UI
does not run a disabled part's bubble-phase pointer and click handlers.
- A non-button wrapper trigger (`<span><MenuButton /></span>`) only relays
events; it takes no button role or tab stop, and Escape returns focus to the
control inside it. A Dropdown that closes with focus inside moves focus back
before its popup unmounts, so a surrounding Modal never claims it.
- A selected item's action runs after Base UI's close completion and focus
return; ActionMenu runs it synchronously inside the selection event so
clipboard writes keep the browser's user activation.
- The mobile submenu disclosure is a menuitem in the arrow-key order and
toggles once per activation. SelectTree parent checkboxes leave the tab order;
Space on the parent row toggles it and Enter or ArrowRight opens its children.
- TreeNavRoot ignores key events from a menu portalled out of a row.
- Listing click exemptions match menu item roles instead of
data-radix-collection-item.
- The single-open coordinator is removed; Base UI's outside-press handling
closes one menu when another opens by pointer.
- Dropdown gains `nativeButton`, inferred from an intrinsic trigger.
- vitest pre-bundles the new @base-ui/react subpaths.
menu-decisions.browser.tsx asserts each of these behaviours directly. The menu
parity record's intended differences are named in the next commit.
Co-Authored-By: Codex (gpt-6.1-sol) <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Same as #2579, but for components that use
useListNavigation. Namely, initially the first non-disabled item is highlighted when opening the list - it's still possible to focus disabled items afterwards.In order for this to work, we still propagate empty
disabledIndicesas an option, but the hook skips the disabled items on initial focus.