Skip to content

[accordion] Fix Trigger data-value and data-index attributes - #5705

Merged
atomiks merged 3 commits into
mui:masterfrom
cpruijsen:fix/issue-5644
Sep 14, 2026
Merged

atomiks merged 3 commits into
mui:masterfrom
cpruijsen:fix/issue-5644

Conversation

@cpruijsen

Copy link
Copy Markdown
Contributor

Accordion.Trigger now uses accordionStateAttributesMapping (value: () => null, index: String(value)), same as Item, Header, and Panel, and overlays triggerOpenStateMapping last so open stays data-panel-open. Triggers no longer render the root's open-values array as data-value="a,b", and they emit data-index on every trigger, including "0".

Fixes #5644

Trigger passed the full item state into useRenderElement with only triggerOpenStateMapping. Unmapped keys go through getStateAttributesProps, which writes data-<key> for any truthy value and drops falsy ones, so the first item (index === 0) had no data-index.

Decision

Emit data-index on every trigger, including "0", and drop data-value, matching Item/Header/Panel. The alternative is to suppress data-index on Trigger as well (index: () => null) so only the documented Trigger attributes remain. Issue #5644 asked for data-index on every trigger or on none, and the other accordion parts already always stringify index.

Can switch to omitting data-index, or add it to AccordionTriggerDataAttributes / the Trigger docs table.

Left alone (same as Item/Header today, and listed on the issue as optional extras): undocumented data-hidden, and data-orientation from the deprecated orientation prop.

Test plan

  • Accordion.Trigger does not render data-value when the root value is ['a', 'b']
  • data-index="0" on the first trigger and data-index="1" on the second
  • Open trigger still has data-panel-open and not data-open
  • Existing Accordion jsdom tests still pass (108 passed, 15 skipped)

@pkg-pr-new

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

commit: 22c43fe

@code-infra-dashboard

code-infra-dashboard Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+17B(0.00%) 🔺+20B(+0.01%)

Details of bundle changes

Performance

Total duration: 1,066.75 ms -202.78 ms(-16.0%) | Renders: 76 (+0) | Paint: 1,726.93 ms -304.98 ms(-15.0%)

Test Duration Renders
Tabs mount (200 instances) 196.03 ms ▼-71.97 ms(-26.9%) 3 (+0)
Tooltip mount (300 contained roots) 47.75 ms ▼-15.76 ms(-24.8%) 1 (+0)
Popover mount (300 instances) 37.14 ms ▼-10.82 ms(-22.6%) 1 (+0)
Combobox open — 500 items 28.53 ms ▼-7.18 ms(-20.1%) 4 (+0)

11 tests within noise — details


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

@netlify

netlify Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

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

@atomiks atomiks added type: bug It doesn't behave as expected. component: accordion Changes related to the accordion component. labels Sep 14, 2026

@atomiks atomiks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix

@atomiks
atomiks merged commit fee18df into mui:master Sep 14, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: accordion Changes related to the accordion component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[accordion] Trigger renders the item state: data-value on every trigger, data-index only when non-zero

2 participants