Skip to content

[Autocomplete] groupBy duplicate #45710

@vilenleung

Description

@vilenleung

Steps to reproduce

const moduleList = [
  {
    "id": 1,
    "stander_id": 1,
    "title": "module1",
    "status": "ACTIVE",
    "created_at": 1743071235,
    "updated_at": 1743074084,
    "stander": {
      "id": 1,
      "title": "stander1",
      "condition": "ALL",
      "status": "ACTIVE",
      "created_at": 1742812980,
      "updated_at": 1742812980
    }
  },
  {
    "id": 5,
    "stander_id": 3,
    "title": "module11",
    "status": "ACTIVE",
    "created_at": 1743074098,
    "updated_at": 1743074098,
    "stander": {
      "id": 3,
      "title": "stander2",
      "condition": "SKIP_SAME_YEAR_WITH_ISSUED_DATE",
      "status": "ACTIVE",
      "created_at": 1742813030,
      "updated_at": 1743074060
    }
  },
  {
    "id": 3,
    "stander_id": 1,
    "title": "module2",
    "status": "ACTIVE",
    "created_at": 1743074075,
    "updated_at": 1743074075,
    "stander": {
      "id": 1,
      "title": "stander1",
      "condition": "ALL",
      "status": "ACTIVE",
      "created_at": 1742812980,
      "updated_at": 1742812980
    }
  },
  {
    "id": 6,
    "stander_id": 3,
    "title": "module22",
    "status": "ACTIVE",
    "created_at": 1743074104,
    "updated_at": 1743074104,
    "stander": {
      "id": 3,
      "title": "stander2",
      "condition": "SKIP_SAME_YEAR_WITH_ISSUED_DATE",
      "status": "ACTIVE",
      "created_at": 1742813030,
      "updated_at": 1743074060
    }
  },
  {
    "id": 4,
    "stander_id": 1,
    "title": "module3",
    "status": "ACTIVE",
    "created_at": 1743074092,
    "updated_at": 1743074092,
    "stander": {
      "id": 1,
      "title": "stander1",
      "condition": "ALL",
      "status": "ACTIVE",
      "created_at": 1742812980,
      "updated_at": 1742812980
    }
  },
  {
    "id": 7,
    "stander_id": 3,
    "title": "module33",
    "status": "ACTIVE",
    "created_at": 1743074109,
    "updated_at": 1743074109,
    "stander": {
      "id": 3,
      "title": "stander2",
      "condition": "SKIP_SAME_YEAR_WITH_ISSUED_DATE",
      "status": "ACTIVE",
      "created_at": 1742813030,
      "updated_at": 1743074060
    }
  }
]

<Autocomplete
    options={moduleList}
    getOptionLabel={(option) => option.title}
    groupBy={(option) => option.stander.title}
    renderInput={(params) => (
      <TextField 
         {...params} 
         variant='outlined' 
         size='small'
       />
     )}
/>

Current behavior

Image

Expected behavior

expect only has two group:
stander1
stander2

Context

No response

Your environment

System:
OS: macOS 14.4.1
Binaries:
Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
pnpm: Not Found
Browsers:
Chrome: 134.0.6998.166
Edge: Not Found
Safari: 17.4.1
npmPackages:
@emotion/react: ^11.14.0 => 11.14.0
@emotion/styled: ^11.14.0 => 11.14.0
@mui/core-downloads-tracker: 7.0.0
@mui/icons-material: ^7.0.0 => 7.0.0
@mui/material: ^7.0.0 => 7.0.0
@mui/private-theming: 7.0.0
@mui/styled-engine: 7.0.0
@mui/system: 7.0.0
@mui/types: 7.4.0
@mui/utils: 7.0.0
@mui/x-date-pickers: ^7.28.0 => 7.28.0
@mui/x-internals: 7.28.0
@types/react: 18.3.3
react: ^18.3.1 => 18.3.1
react-dom: ^18.3.1 => 18.3.1

Search keywords: Autocomplete groupBy duplicate

Metadata

Metadata

Assignees

Labels

scope: autocompleteChanges related to the autocomplete. This includes ComboBox.support: questionCommunity support but can be turned into an improvement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions