Skip to content

[navigation menu] Add generic Value typing#4328

Merged
atomiks merged 3 commits intomui:masterfrom
atomiks:codex/navigation-menu-generic-value-typing
Mar 19, 2026
Merged

[navigation menu] Add generic Value typing#4328
atomiks merged 3 commits intomui:masterfrom
atomiks:codex/navigation-menu-generic-value-typing

Conversation

@atomiks
Copy link
Copy Markdown
Contributor

@atomiks atomiks commented Mar 13, 2026

Summary

Adds generic value typing to NavigationMenu.Root so value, defaultValue, and onValueChange infer the selected item type the same way Accordion already does. This keeps the existing permissive default when no generic is provided while improving type safety for controlled and uncontrolled usage.

Changes

  • Add a NavigationMenuValue<Value> alias and thread the generic through NavigationMenu.Root props and namespace exports.
  • Update the root context typing so the internal setter matches the public generic value shape.
  • Add compile-time spec coverage for inference, explicit generics, nullable values, and the backward-compatible any default.
  • Regenerate the Navigation Menu API reference metadata.

@atomiks atomiks added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. typescript component: navigation menu Changes related to the navigation menu component. labels Mar 13, 2026
@atomiks
Copy link
Copy Markdown
Contributor Author

atomiks commented Mar 13, 2026

Codex Review

Overview

This patch adds generic value typing to NavigationMenu.Root so value, defaultValue, and onValueChange infer the selected item type instead of defaulting to any. It also adds compile-time coverage and updates the generated API reference so the docs show the simpler Value | null form.

Findings (None)

No blocking issues found in this patch.

Confidence: 4/5

High confidence based on a full review of the branch diff, a second-pass sweep for render correctness, accessibility impact, API and state design, maintainability, performance risk, and test coverage, plus validation with pnpm typescript, pnpm test:jsdom NavigationMenuRoot --no-watch, pnpm docs:api, pnpm eslint, pnpm stylelint, and pnpm markdownlint.

Notes

  • The runtime behavior is unchanged; the patch is limited to public typing, compile-time assertions, internal context typing, and generated API metadata.
  • I did not run a benchmark because the change does not alter hot-path runtime logic, layout work, or bundle size.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 13, 2026

commit: af9ac6a

@mui-bot
Copy link
Copy Markdown

mui-bot commented Mar 13, 2026

Bundle size report

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

Details of bundle changes


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

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 13, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit af9ac6a
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69bb4262af0f1d0008462613
😎 Deploy Preview https://deploy-preview-4328--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@atomiks atomiks changed the title [navigation menu] Add generic value typing [navigation menu] Add generic Value typing Mar 13, 2026
@atomiks atomiks marked this pull request as ready for review March 13, 2026 07:36
@atomiks atomiks merged commit 55b27a6 into mui:master Mar 19, 2026
23 checks passed
@atomiks atomiks deleted the codex/navigation-menu-generic-value-typing branch March 19, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: navigation menu Changes related to the navigation menu component. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants