Skip to content
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

fix(Select): support array value when using multiple #277

Open
wants to merge 1 commit into
base: 5.0
Choose a base branch
from

Conversation

prescottprue
Copy link

@prescottprue prescottprue commented Aug 29, 2018

Issue

Using multiple option with Select like so:

<FormControl>
  <InputLabel htmlFor="some">My Field</InputLabel>
  <Field
    name={name}
    component={Select}
    fullWidth
    name="some"
    placeholder="Select Some Items">
      <MenuItem value={10}>Ten</MenuItem>
      <MenuItem value={20}>Twenty</MenuItem>
      <MenuItem value={30}>Thirty</MenuItem>
    ))}
  </Field>
</FormControl>

Produces the following error:
image

The exact message is:

Uncaught Error: Material-UI: the `value` property must be an array when using the `Select` component with `multiple`.`

Dependencies Versions

For those trying to replicate, here are my dependencies versions

  • redux-form-material-ui - 5.0.0-beta.3
  • @material-ui/core - 3.0.0
  • react + react-dom - ^16.3.0

Solution

If the value is not an array and props.multiple is enabled, an empty array is returned. This handles the case of a SelectField that has multiple

@codecov
Copy link

codecov bot commented Aug 29, 2018

Codecov Report

Merging #277 into 5.0 will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              5.0     #277   +/-   ##
=======================================
  Coverage   66.66%   66.66%           
=======================================
  Files           8        8           
  Lines          24       24           
=======================================
  Hits           16       16           
  Misses          8        8
Impacted Files Coverage Δ
src/Select.js 20% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9328e93...77a603f. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant