mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.38k stars 32.14k forks source link

[SELECT] Mui-selected class always gets applied in the first MenuItem when rendering my Select Group component #32814

Open reigun02 opened 2 years ago

reigun02 commented 2 years ago

Duplicates

Latest version

Current behavior 😯

I'm trying to do a list dropdown where my menu items are grouped by some category. Unfortunately, the first item in the first group is always highlighted when I'm implementing grouping in the menu items. The issue is not existing in the old material UI Select component

image image

Expected behavior 🤔

Mui-selected class should not be applied in the first item of my list

Steps to reproduce 🕹

https://codesandbox.io/s/select-group-issue-3862fj?file=/src/Demo.tsx

Context 🔦

Mui-selected class should not be applied in the first item of selection list

Your environment 🌎

`npx @mui/envinfo` ``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```
siriwatknp commented 2 years ago

I haven't looked into the implementation of the Select but from the behavior, it looks like a bug to me. It should not have Mui-selected if there is no selected option yet.