Skip to content

[Autocomplete] groupBy duplicate #45710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vilenleung opened this issue Mar 27, 2025 · 2 comments
Closed

[Autocomplete] groupBy duplicate #45710

vilenleung opened this issue Mar 27, 2025 · 2 comments
Assignees
Labels
support: question Community support but can be turned into an improvement

Comments

@vilenleung
Copy link

vilenleung commented Mar 27, 2025

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

@vilenleung vilenleung added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 27, 2025
@vilenleung vilenleung changed the title [MUI V7] [MUI V7] Autocomplete groupBy duplicate Mar 27, 2025
@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 27, 2025
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@DiegoAndai DiegoAndai self-assigned this Mar 27, 2025
@DiegoAndai DiegoAndai changed the title [MUI V7] Autocomplete groupBy duplicate [Autocomplete] groupBy duplicate Mar 27, 2025
@DiegoAndai DiegoAndai added support: question Community support but can be turned into an improvement status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 27, 2025
@DiegoAndai
Copy link
Member

Hey @vilenleung, thanks for the report. You beat me to close the issue, seems like you found the answer. For anyone finding this issue, you need to sort the options on the same dimension that they are grouped by: https://mui.com/material-ui/react-autocomplete/#grouped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants