-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Description
Steps to reproduce
Steps:
- Open this link to live example: https://stackblitz.com/edit/react-mpdrbwbo?file=Demo.tsx, look at
BasicSelect - open select
Current behavior
Select passes selected based on value and ignores existing value of selected of MenuItem.
Expected behavior
Select passes selected based on value, but only if it's undefined.
Context
This might be sort of X-Y problem.
The stackblitz link contains another element - ComplicatedSelect. This more closely resembles select from my app.
I'm trying to implement Select all option, and the only thing that is blocking me is selected not working.
With selected={selectAllValue !== 'none'} I expect it to be hightlighted, whenever at least one element is selected, but it is never selected, because it's not in value prop.
I can put the value of the Select all checkbox in the value array on the fly, but that would also require adding magical -1 in renderValue which feels brittle, but most imporantly, it results in onChange breaking becase it will not be in event.target.value after click.
Your environment
npx @mui/envinfo
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
Search keywords: select selected MenuItem overrides undefined