When you wrap ListSubheader & MenuItems inside <TextField select /> in an element, like div, the value is lost (=undefined) on the next onChange.
You are not allowed to use react fragments and when you use an element to dynamically map to a single root, value becomes undefined onChange.
It should be possible to either use fragment or wrap the above components in another element.
https://codesandbox.io/s/wizardly-snowflake-l7lu4
Steps:
| Tech | Version |
| ----------- | ------- |
| Material-UI | v4.8.0 |
| React | 16.8.4 |
| Browser | firefox 71 |
| TypeScript | 3.3.3 |
You have to apply the value prop on the outer most element, this is related to #14943.
It does not make sense to do so on 1. a div (value prop does not exist) and 2. using grouping, because there are multiple possible values.
So this basically means, dynamically grouping is not possible?
@akomm You can add an intermediary component do ignore the value prop from the outer element (the div). Dynamic grouping is possible, as long as you keep a flat array, like in the existing demo.
Thanks.
The example did not really help, as it uses static definitions, not dynamic.
But I figured it out now myself - no intermediary component needed (also no dead value).
For those, who might seek for the solution: https://codesandbox.io/s/silly-mclaren-k7qul
Thanks for sharing, this would be perfect on StackOverflow.