Skip to content

[docs] New mobile nav/search - #5137

Merged
aarongarciah merged 87 commits into
mui:masterfrom
aarongarciah:docs-mobile-nav
Jul 10, 2026
Merged

aarongarciah merged 87 commits into
mui:masterfrom
aarongarciah:docs-mobile-nav

Conversation

@aarongarciah

@aarongarciah aarongarciah commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Before

The "mobile" navigation and search are two separate dialogs that are highly repetitive: before typing in the search input, a set of default search results are displayed, and these results are basically the same as the nav links.

Simulator.Screen.Recording.-.iPhone.17.-.2026-06-30.at.15.37.51.mov

After

A new drawer with a unified nav and search for "mobile": the drawer displays a static link list when opened, but when the user types in the input, the static link list gets hidden and the autocomplete results are displayed in its place, using the same styles.

The mobile nav/search trigger now uses a magnifying glass icon instead of the "menu" icon to help users discover the search capability.

I was a bit worried about hiding/showing the static link list, but after playing a while with it, feels pretty nice. It could get a bit confusing for a keyboard user in a small viewport because the static link list and the autocomplete results have different tab interactions (multiple tab stops vs single tab stop).

An alternative approach would be to remove the static link list altogether and use default autocomplete results instead (same approach as the desktop search).

Simulator.Screen.Recording.-.iPhone.17.-.2026-07-08.at.11.27.51.mov

The drawer radius and handle are inspired by iOS. This is a screenshot from the iOS Maps app.

Screenshot 2026-06-30 at 23 51 09

@aarongarciah aarongarciah added the docs Improvements or additions to the documentation. label Jun 29, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5137
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5137
    

commit: 18bd0e1

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 0B(0.00%) 0B(0.00%)

Details of bundle changes

Performance

Total duration: 1,439.18 ms -41.30 ms(-2.8%) | Renders: 78 (+0) | Paint: 2,212.81 ms -84.82 ms(-3.7%)

Test Duration Renders
Select mount (200 instances) 175.78 ms 🔺+38.54 ms(+28.1%) 3 (+0)
Combobox type — 500 items, narrows to ~11 (type "Row 25") 41.08 ms 🔺+11.61 ms(+39.4%) 17 (+0)
Combobox type — 500 items, all stay mounted (type "Row ") 33.82 ms 🔺+7.96 ms(+30.8%) 11 (+0)
Slider mount (300 instances) 147.40 ms ▼-59.31 ms(-28.7%) 3 (+0)
Checkbox mount (500 instances) 60.58 ms ▼-22.13 ms(-26.8%) 1 (+0)

…and 2 more (+7 within noise) — details

Metric alarms

Test Metric Change
Select mount (200 instances) bench:paint 🔺 +54.25 ms
Combobox type — 500 items, narrows to ~11 (type "Row 25") bench:paint#combobox-open 🔺 +20.39 ms
Combobox type — 500 items, narrows to ~11 (type "Row 25") bench:paint 🔺 +20.39 ms
Combobox type — 500 items, all stay mounted (type "Row ") bench:paint#combobox-open 🔺 +16.19 ms
Combobox type — 500 items, all stay mounted (type "Row ") bench:paint 🔺 +16.19 ms

Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 18bd0e1
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a4fe7d121d0f40008fa63d1
😎 Deploy Preview https://deploy-preview-5137--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@aarongarciah
aarongarciah marked this pull request as ready for review June 30, 2026 15:18
@aarongarciah
aarongarciah marked this pull request as draft June 30, 2026 15:34
@aarongarciah
aarongarciah marked this pull request as ready for review June 30, 2026 23:51
@aarongarciah
aarongarciah marked this pull request as draft June 30, 2026 23:55
@aarongarciah
aarongarciah requested a review from atomiks July 1, 2026 07:24
@aarongarciah
aarongarciah marked this pull request as ready for review July 1, 2026 09:02
@aarongarciah
aarongarciah requested review from dav-is and jjenzz July 1, 2026 09:07

@aarongarciah aarongarciah Jul 1, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dav-is I'm adding analytics to the mobile nav. May I ask you to check if it looks good?

@atomiks

atomiks commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

PR review

One merge-blocking finding: a unitless 0 fallback in the new drawer CSS invalidates the calc() expressions that drive the scroll viewport's bottom inset, so the bottom padding, fade scrims, and scroll padding silently collapse in the drawer's default state. The rest is a low-impact keyboard-shortcut regression and duplication between the two search implementations.

Bugs (3)

1. 🔴 Unitless 0 fallback makes the scroll-inset calc() invalid until the search input is focused

Location: docs/src/components/MobileNav.css (.MobileNavScrollAreaRoot)

--mobile-nav-scroll-bottom-inset: calc(
  var(--mobile-nav-bleed) + var(--drawer-keyboard-inset, 0)
);

--drawer-keyboard-inset is not a registered CSS property; DrawerVirtualKeyboardProvider only sets it (as 0px or a real inset) once a keyboard-input target inside the drawer gains focus. On a fresh open where the user just browses nav links (initial focus goes to the popup, and iOS doesn't focus links on tap), the var is unset, so the fallback applies — and calc(3rem + 0) is <length> + <number>, which is invalid CSS. Substituted through var(), every property consuming it becomes invalid at computed-value time and falls back to unset: the viewport's padding-bottom and scroll-padding-bottom, the entire mask-image (top and bottom fade scrims disappear), and the scrollbar's padding-bottom.

Failure scenario: Open the drawer and scroll to the bottom without ever tapping the search field: the last nav item sits behind the 3rem off-screen bleed (only partially rescued by env(safe-area-inset-bottom) on notched iPhones — fully clipped elsewhere), and no fade scrims render. Everything self-heals the moment the search input is focused once, which makes it easy to miss in testing.

Fix: var(--drawer-keyboard-inset, 0px).

2. 🟡 Cmd+K is dead on the website layout at small viewports

Location: docs/src/components/SearchControls.tsx

const visibleTarget =
  getVisibleTarget(desktopTriggerRef.current) ?? getVisibleTarget(mobileTriggerRef.current);
if (!visibleTarget) {
  return;
}

On the (website) layout, SearchControls renders without mobileNavContent, and its container is display: none below bp3. Previously enableKeyboardShortcut called handle.open() unconditionally, so Cmd+K opened the search dialog even with the trigger hidden. Now both triggers fail getClientRects().length and the shortcut does nothing.

Failure scenario: iPad in portrait with a hardware keyboard (or a narrow desktop window) on the homepage — Cmd+K silently does nothing where it used to open search.

Fix: When no trigger is visible, fall back to opening the desktop dialog (or the drawer when hasMobileNav), rather than returning.

3. ℹ️ titleMap removal changes the desktop side nav label

Location: docs/src/app/(docs)/layout.tsx

Removing titleMap means the desktop SideNav now renders "About Base UI" instead of the shortened "About". That's a desktop-visible change in a mobile-nav PR — confirm it's intended (and that the longer label doesn't wrap awkwardly in the sidebar).

Tests (0)

No findings.

Simplifications (2)

1. 🟡 ~120 lines of search plumbing duplicated between the drawer and the dialog

Location: docs/src/components/MobileNavDrawer.tsx

MobileNavDrawer re-implements, nearly verbatim from SearchDialog: the GA search-session tracking (searchQueryRef/resultCountRef/attemptRef/selectedResultRef/lastTrackedQueryRef, the 1500ms query debounce, and the select/dismiss close event), SEMVER_PATTERN + slugifyWithParentContext, normalizeGroup, and the 400ms empty-results delay. It also declares its own sitemapPromise instead of reusing loadSearchSitemap — which this same PR added specifically to share the promise and retry after a failed load, so the drawer's copy misses the catch-and-reset behavior and the two entry points don't share the cached import.

Failure scenario: The two search surfaces drift — an analytics or slug fix lands in one and not the other, and the duplicated logic is the bulk of the new 475-line file.

Fix: Extract a shared useSearchTracking(ga) hook plus shared slug/group helpers (e.g. in Search/), and use loadSearchSitemap in MobileNavDrawer.

2. ℹ️ MobileNav.Item link branches can collapse into a spread

Location: docs/src/components/MobileNav.tsx

linkProps uses camelCase keys (ariaCurrent, dataActive) that are then manually re-mapped onto two near-identical JSX branches. Building the object with real attribute keys ('aria-current', 'data-active', …) lets both branches spread it: <a {...linkProps} /> vs <NextLink {...linkProps} scroll={false} onNavigate={handleNavigate} />, removing ~20 lines.

Docs (0)

No findings.

Verdict

Request changes — the unitless calc() fallback silently disables the drawer's bottom inset, scrims, and scroll padding in its default state (one-character fix).


🤖 Review generated with Claude Code

@aarongarciah

Copy link
Copy Markdown
Member Author

@atomiks tackled the feedback points:

  • Fixed the drawer inset fallback to 0px, so the scroll padding/scrims stay valid before the keyboard inset variable is set.
  • Restored the shortened About label and moved the logic into a shared getDisplayTitle helper so the side nav/mobile nav/search stay consistent.
  • Fixed the small-viewport Cmd+K fallback so it still opens the desktop dialog on website pages, or the drawer when mobile nav is available.
  • Reduced the duplicated search plumbing by extracting shared search tracking, result helpers, deferred empty-state handling, and the shared docs search setup.
  • Simplified MobileNav.Item by using real attribute keys in linkProps and spreading them into both link branches.

I also kept the dialog/drawer lazy-loaded, with idle preloading plus immediate request-time loading so the first interaction does not silently no-op while the chunk is loading.

@aarongarciah
aarongarciah force-pushed the docs-mobile-nav branch 2 times, most recently from 7e24289 to f129ac7 Compare July 3, 2026 11:52
@@ -1,3 +1,5 @@
@layer all, base, theme, components, utilities;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this to every component to avoid future issues with async loaded components declaring CSS layers before the first @layer all, base, theme, components, utilities; instance and hence causing styles to break.

@zannager
zannager removed the request for review from dav-is July 7, 2026 11:52
aarongarciah and others added 25 commits July 9, 2026 19:11
Escape during IME composition cancels the composition natively, but the
capture handler also cleared the committed query. Skip handling while
composing; keyCode 229 covers Safari where isComposing is unreliable.

Co-Authored-By: Claude Fable 5 <[email protected]>
The desktop search index build was gated behind onOpenChangeComplete, so
the first open showed an empty body during the transition and popped in
the default results once indexing landed. Warm the index shortly after
mount instead so the default results are ready before the first open, and
keep the index active across reopens.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
aarongarciah and others added 2 commits July 9, 2026 19:31
isSearchPending required isReady, so a query typed before the lazy index
finished building fell through as "not pending" while results had already
collapsed to the defaults. Consumers then rendered the default list under a
real query (reachable on mobile, where the deferred loader activates only
after the drawer opens). Treat a not-ready query the same as an in-flight one.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@aarongarciah

Copy link
Copy Markdown
Member Author

The drawer now pauses on release which stops its momentum:

Should be fixed now.

@aarongarciah
aarongarciah merged commit aa4af39 into mui:master Jul 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to the documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants