Skip to content

[select] Fix items type definition for groups - #3884

Merged
atomiks merged 4 commits into
mui:masterfrom
aarongarciah:docs-select-grouped-demo
Feb 24, 2026
Merged

atomiks merged 4 commits into
mui:masterfrom
aarongarciah:docs-select-grouped-demo

Conversation

@aarongarciah

@aarongarciah aarongarciah commented Jan 29, 2026 •

Copy link
Copy Markdown
Member

While adding a grouped demo in the Select docs, I realized the items prop didn't accept an array of groups.

This change expands the items type to also accept an array of groups with these shapes:

const groups1 = [
  {
    value: 'Fruits',
    items: ['Apple', 'Banana']
  },
  {
    value: 'Vegetables',
    items: ['Broccoli', 'Carrot']
  }
];

const groups2 = [
  {
    value: 'Fruits',
    items: [
      { value: 'apple', label: 'Apple' },
      { value: 'banana', label: 'Banana' }
    ]
  },
  {
    value: 'Vegetables',
    items: [
      { value: 'broccoli', label: 'Broccoli' },
      { value: 'carrot', label: 'Carrot' }
    ]
  }
];

@aarongarciah aarongarciah added component: select Changes related to the select component. docs Improvements or additions to the documentation. on hold There is a blocker, we need to wait. labels Jan 29, 2026
@pkg-pr-new

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

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

  • vite-css-base-ui-example

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

commit: fc5f9c1

@mui-bot

mui-bot commented Jan 29, 2026 •

Copy link
Copy Markdown

Bundle size report

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

Details of bundle changes


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

@netlify

netlify Bot commented Jan 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit fc5f9c1
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/699d36d07f913b0008316ca7
😎 Deploy Preview https://deploy-preview-3884--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.

@aarongarciah
aarongarciah force-pushed the docs-select-grouped-demo branch 3 times, most recently from 4de4785 to 8b6fac2 Compare January 29, 2026 10:54
@aarongarciah aarongarciah changed the title [docs][select] Add grouped demo [select] Fix items type definition for groups Feb 4, 2026
@aarongarciah
aarongarciah requested a review from Copilot February 4, 2026 14:07

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 extends the Select component’s items typing to support grouped item data structures and adds documentation + demos illustrating grouped usage.

Changes:

  • Generalizes the utility types in resolveValueLabel to accept grouped items via a shared Group interface and reuses this in Select’s store and root props.
  • Updates Select’s public API typing (SelectRootProps.items and generated JSON reference) to include grouped item shapes, mirroring existing Combobox/Autocomplete support.
  • Adds a new “Grouped” section, navigation entry, and CSS Modules + Tailwind demos for grouped Select usage in the docs.

Reviewed changes

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

Show a summary per file
File Description
packages/react/src/utils/resolveValueLabel.tsx Extends ItemsInput to include ReadonlyArray<Group<any>> / ReadonlyArray<Group<LabeledItem>>, defines and exports a reusable Group<Item> interface, and uses isGroupedItems to support grouped arrays in hasNullItemLabel and resolveSelectedLabel.
packages/react/src/select/store.ts Aligns the Select store’s State['items'] type with the new grouped shapes by allowing ReadonlyArray<Group<any>> and ReadonlyArray<Group<{ label: React.ReactNode; value: any }>>, reusing the shared Group type.
packages/react/src/select/root/SelectRoot.tsx Imports Group from the shared utility and updates SelectRootProps['items'] to accept records, flat labeled arrays, and grouped arrays (both generic Group<any> and labeled Group<{ label; value }>), matching the underlying store and resolver behavior.
docs/src/app/(docs)/react/components/select/page.mdx Adds a “Grouped” documentation section describing grouped data structures, includes an example ProduceGroupItem interface, and wires in the new DemoSelectGrouped demo.
docs/src/app/(docs)/react/components/select/demos/grouped/tailwind/index.tsx Introduces a Tailwind-based grouped Select demo that passes a grouped items array to <Select.Root> and renders <Select.Group> / <Select.GroupLabel> / <Select.Item> from the same dataset.
docs/src/app/(docs)/react/components/select/demos/grouped/index.ts Registers DemoSelectGrouped via createDemoWithVariants, consistent with other Select demos.
docs/src/app/(docs)/react/components/select/demos/grouped/css-modules/index.tsx Adds a CSS Modules–styled grouped Select demo mirroring the Tailwind variant, using the grouped items array and group components for headings and items.
docs/src/app/(docs)/react/components/select/demos/grouped/css-modules/index.module.css Provides the styling for the CSS Modules grouped demo (field layout, trigger, popup, grouped list, sticky group labels, items, and scroll arrows).
docs/src/app/(docs)/react/components/page.mdx Updates the Select section’s outline to include a “Grouped” entry alongside existing topics like Multiple selection and Object values.
docs/reference/generated/select-root.json Updates the generated API reference for SelectRoot.items to document the new union of record, flat labeled array, and grouped array shapes (including Group[] and Group<{ label, value }>[]).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 13, 2026
@atomiks
atomiks force-pushed the docs-select-grouped-demo branch from 8b6fac2 to 7dd06d5 Compare February 22, 2026 11:01
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 22, 2026
@atomiks
atomiks force-pushed the docs-select-grouped-demo branch from 167ca88 to 11e3455 Compare February 24, 2026 04:01
@atomiks
atomiks force-pushed the docs-select-grouped-demo branch from 776c60f to 62b9cd8 Compare February 24, 2026 04:25
@atomiks
atomiks marked this pull request as ready for review February 24, 2026 05:27
@atomiks atomiks removed the on hold There is a blocker, we need to wait. label Feb 24, 2026
@atomiks
atomiks merged commit cbbb755 into mui:master Feb 24, 2026
8 checks passed
@atomiks atomiks removed the docs Improvements or additions to the documentation. label Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: select Changes related to the select component. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants