mui-org/material-ui

[Select] Support native multiple value #13629

mcfletch posted onGitHub

The native property on <Select /> components will cause the use of the <NativeSelect /> component to implement the select, but the NativeSelect does not allow for arrays for the value property, nor will it render multiple into the final <select />.

There would seem to be two ways to deal with this:

  • make it possible to use native and multiple
  • document that the combination doesn't work

What happens currently is that you get a warning like so:

react-dom.development.js:518 Warning: The `value` prop supplied to <select> must be a scalar value if `multiple` is false```
when creating an element like so:

<Select native={true} multiple={true} value={[1,2,3]} fullWidth> <option value={1}>Example</option> <option value={2}>Other</option> <option value={3}>Last</option> </Select>```

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Select element should either pass multiple through to the underlying select in NativeSelect or it should validate/reject the use of both multiple and native on the same component.

Current Behavior

The two props can both be true, but the component prints a log message about the invalid array value and acts as a single-item select.

Steps to Reproduce

https://codesandbox.io/s/z2n8884owm

  1. Run the above code sample
  2. Note the error in the console about the value property
  3. Note that the rendered select is not a multi-select (no multiple on the rendered html, no ability to select multiple)

Context

We're finding that the non-native Select is "popping under" our dialogs, so we'd wanted to switch to using the native multiple-select, however, when we chose the combined properties it produced a single-select.

Your Environment

Tech Version
Material-UI v3.3.2
React 16.3

Fund this Issue

$40.00
Rewarded

Rewarded pull request

Recent activities

rfbotto was rewarded by oliviertassinari for mui-org/material-ui# 13629
about 6 years ago
rfbotto submitted an output to  mui-org/ material-ui# 13629
over 6 years ago