Skip to content

[navigation-menu] Add disabled data attribute to NavigationMenu.Trigger - #5521

Merged
sai6855 merged 6 commits into
mui:masterfrom
sai6855:nav-trigger-disabled
Aug 17, 2026
Merged

sai6855 merged 6 commits into
mui:masterfrom
sai6855:nav-trigger-disabled

Conversation

@sai6855

@sai6855 sai6855 commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

A disabled NavigationMenu.Trigger didn't expose data-disabled (unlike every other trigger), because disabled was missing from its state, it was only inherited from NativeButtonProps, so it was also undocumented. This adds disabled to the state, props, enum, and generated docs, with a regression test.

@sai6855 sai6855 changed the title [trigger] Add disabled data attribute to NavigationMenu.Trigger [navigation-menu] Add disabled data attribute to NavigationMenu.Trigger Aug 17, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 17, 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@5521
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5521
    

commit: 1d8d76f

@code-infra-dashboard

code-infra-dashboard Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+14B(0.00%) 🔺+4B(0.00%)

Details of bundle changes

Performance

Total duration: 1,487.55 ms +85.27 ms(+6.1%) | Renders: 76 (+0) | Paint: 2,308.72 ms +143.07 ms(+6.6%)

Test Duration Renders
Menu mount (300 instances) 141.04 ms 🔺+26.59 ms(+23.2%) 1 (+0)

14 tests within noise — details

Metric alarms

Test Metric Change
Menu mount (300 instances) bench:paint 🔺 +39.19 ms

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

@netlify

netlify Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1d8d76f
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a82b72f310a14000897e561
😎 Deploy Preview https://deploy-preview-5521--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.

@sai6855 sai6855 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. component: navigation menu Changes related to the navigation menu component. labels Aug 17, 2026
@sai6855

sai6855 commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

@claude review

@github-actions

github-actions Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

ized# PR review

Nothing merge-blocking. The runtime change is correct — disabled now flows into the trigger's state, and getStateAttributesProps' default mapping turns it into data-disabled, matching Dialog/Select/Accordion/Combobox/Autocomplete triggers. Two things worth fixing first: types.md was hand-edited rather than regenerated (CONTRIBUTING forbids this, and the table is misaligned in a way pnpm docs:api + prettier would not produce), and the newly documented public disabled prop still has no behavioral test.

Tests (1)

1. 🟠 No behavioral coverage for the now-public disabled prop

Location: packages/react/src/navigation-menu/trigger/NavigationMenuTrigger.test.tsx:138

it('applies the data-disabled style hook only when disabled', async () => {

This PR promotes disabled from an incidental pass-through into a documented public prop of NavigationMenu.Trigger (JSDoc, props table, state, data attribute). The only new test asserts the style hook; grepping the whole 612-line test file shows disabled appears nowhere else, so none of the behavior the docs now advertise is pinned.

Notably, the keyboard-open path in defaultProps.onKeyDown (NavigationMenuTrigger.tsx:693) has no disabled guard of its own:

if (openHorizontal || openVertical) {
  setValue(itemValue, createChangeEventDetails(REASONS.listNavigation, event.nativeEvent));
  handleOpenEvent(event);
  stopEvent(event);
}

It is safe today only because getButtonProps is the last entry in props={[…]} (line 748-754), so useButton's onKeyDown short-circuits before calling the merged external handler.

Failure scenario: Someone reorders the props array (e.g. moves getButtonProps before defaultProps, or inserts a new props source after it) and a disabled horizontal trigger opens its popup on ArrowDown. No test fails. Likewise, nothing asserts that a disabled trigger stays focusable (focusableWhenDisabled: true) with aria-disabled="true" rather than the native disabled attribute — a regression there would silently break keyboard reachability of the disabled item in the composite list.

Fix: Add assertions alongside the style-hook test: disabled trigger does not open on click, does not open on ArrowDown (horizontal orientation), does not open on hover, and exposes aria-disabled="true" while remaining focusable / tabbable.

Docs (1)

1. 🟠 types.md is autogenerated and was edited by hand

Location: docs/src/app/(docs)/react/components/navigation-menu/types.md:117

| data-popup-open | -    | Present when the corresponding navigation menu is open. |
| data-pressed    | -    | Present when the trigger is pressed.                    |
| data-disabled   | -    | Present when the trigger is disabled.                 |

CONTRIBUTING.md:218 states: "types.md files … are autogenerated. Do not edit them manually." The new row proves the file was edited directly rather than regenerated: the description column is one space short of the table's 55-character width (Present when the corresponding navigation menu is open. is 55 chars; Present when the trigger is disabled. is 37 and is followed by 17 spaces instead of 18). Neither the generator nor prettier produces a misaligned markdown table.

The prop-row placement is also unverified. Comparing against the generated Menu.Trigger table (docs/src/app/(docs)/react/components/menu/types.md:112-124), the generator's prop ordering (handle, nativeButton, payload, disabled, openOnHover, …) matches neither declaration order nor alphabetical order, so where disabled actually lands relative to nativeButton here can't be predicted from the source — it has to be regenerated to know.

Failure scenario: CI's format check (prettier over markdown, .lintignore does not exclude docs/) fails on the misaligned row, and pnpm docs:validate / pnpm docs:api regenerates the file into a dirty diff — possibly with the disabled row in a different position than the one committed here.

Fix: Revert the manual edits to types.md and run pnpm docs:api (or pnpm docs:validate) to regenerate it from the source JSDoc, then commit the generated output. The content in the state block (open then disabled, matching the interface declaration order) already looks right — this is about letting the generator produce it.

Notes (1)

1. ℹ️ Menu.Trigger and Popover.Trigger have the same undocumented data-disabled

Location: packages/react/src/navigation-menu/trigger/NavigationMenuTriggerDataAttributes.ts:15

MenuTriggerState (MenuTrigger.tsx:215-218) and PopoverTriggerState (PopoverTrigger.tsx:125-128) both already carry disabled in state, so both already emit data-disabled — but neither MenuTriggerDataAttributes nor PopoverTriggerDataAttributes declares it, so their docs tables omit it too. This PR's approach is the correct one (it matches Dialog, AlertDialog, Select, Accordion, Combobox, Autocomplete, and Menu.SubmenuTrigger); those two are the remaining stragglers.

Failure scenario: A user styling Menu.Trigger[data-disabled] has to discover the attribute by inspecting the DOM, since the docs don't list it.

Fix: Optional follow-up — add disabled = 'data-disabled' to MenuTriggerDataAttributes and PopoverTriggerDataAttributes and regenerate those types.md files.

Verdict

Approve after nits — the runtime change is correct and consistent with sibling triggers; the blockers-in-practice are the hand-edited generated docs file and the missing behavioral tests for the now-public disabled prop.


🤖 Review generated with Claude Code · Opus 5 (High) · medium review depth · 38 turns · 5m6s · $1.96 · run

@sai6855
sai6855 marked this pull request as ready for review August 17, 2026 07:33
Copilot AI lite review requested due to automatic review settings August 17, 2026 07:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns NavigationMenu.Trigger with other trigger components by formally exposing disabled in its public props/state so consumers can style it via the data-disabled attribute and see disabled documented in the generated API docs.

Changes:

  • Added data-disabled to NavigationMenuTriggerDataAttributes.
  • Added disabled to NavigationMenuTrigger props + state, ensuring the state-driven data-disabled hook is emitted.
  • Added a regression test and updated generated docs to include the disabled prop and data-disabled attribute.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/react/src/navigation-menu/trigger/NavigationMenuTriggerDataAttributes.ts Adds data-disabled to the trigger’s documented data-attribute hooks.
packages/react/src/navigation-menu/trigger/NavigationMenuTrigger.tsx Plumbs disabled into component state/props so data-disabled can be produced and documented.
packages/react/src/navigation-menu/trigger/NavigationMenuTrigger.test.tsx Adds a regression test ensuring data-disabled is present only when disabled is true.
docs/src/app/(docs)/react/components/page.mdx Updates the component index listing to include disabled and data-disabled for Navigation Menu Trigger.
docs/src/app/(docs)/react/components/navigation-menu/types.md Updates generated API docs (props/state + data attributes) to include disabled and data-disabled.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sai6855
sai6855 merged commit f4cad1e into mui:master Aug 17, 2026
6 checks passed
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants