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

Error in multiple Select: Cannot read properties of undefined (reading 'value') at SelectInput.js:394:63 #43004

Closed
arinsinc opened this issue Jul 20, 2024 · 4 comments
Assignees
Labels
component: select This is the name of the generic UI component, not the React module!

Comments

@arinsinc
Copy link

arinsinc commented Jul 20, 2024

Steps to reproduce

This is my select component:

     <FormControl size='small'>
          <InputLabel id="demo-simple-select-label">
              Groups
           </InputLabel>
           <Select
                variant='outlined'
                labelId="demo-simple-select-label"
                id="demo-simple-select"
                multiple
                value={formState.values.groups}
                onChange={handleChange}
                input={<OutlinedInput label="Groups" />}
                label="Group"
                name="groups"
           >
                {addMenuItem}
           </Select>
           <FormHelperText>
                {hasError('groups') ? formState.errors['groups'] : null}
           </FormHelperText>
      </FormControl>

     const addMenuItem = groups.map((option) => (
            <MenuItem key={option} value={option}>{option}</MenuItem>
     ));

It is failing in SelectInput.js at this line:
Screenshot 2024-07-20 at 09 09 12

Current behavior

Not able to open form component with select component attached

Expected behavior

Should able to select multiple values in a form

Context

Issue with the <InputLabel>, if I remove this component, form has been rendered but without any label

Your environment

  • Google Chrome latest version
  • MUI latest version
npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: select input

@arinsinc arinsinc added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 20, 2024
@sai6855
Copy link
Contributor

sai6855 commented Jul 22, 2024

 <FormControl size='small'>
      <InputLabel id="demo-simple-select-label">
          Groups
       </InputLabel>
       <Select
            variant='outlined'
            labelId="demo-simple-select-label"
            id="demo-simple-select"
            multiple
            value={formState.values.groups}
            onChange={handleChange}
            input={<OutlinedInput label="Groups" />}
            label="Group"
            name="groups"
       >
            {groups.map((option) => (
        <MenuItem key={option} value={option}>{option}</MenuItem>
 ))}
       </Select>
       <FormHelperText>
            {hasError('groups') ? formState.errors['groups'] : null}
       </FormHelperText>
  </FormControl>

@arinsinc can you try this?

@sai6855 sai6855 added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 22, 2024
@arinsinc
Copy link
Author

@sai6855 No, it is not working.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Jul 22, 2024
@sai6855
Copy link
Contributor

sai6855 commented Jul 22, 2024

Can you please share code sandbox / repo to clone which reproduces the issue?

@zannager zannager added the component: select This is the name of the generic UI component, not the React module! label Jul 22, 2024
@sai6855 sai6855 added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 22, 2024
@arinsinc
Copy link
Author

It is working in sandbox as isolated component, don't know why? Will check the parent component and whole chain of parent-child components.

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

3 participants