3

I am using the Select with the multiple prop. The component works fine, and the InputLabel renders the renders the following:

enter image description here

However, when I add an icon at the beginning via the startAdornment prop, the InputLabel is moved above the input field.

enter image description here

Do you know how to show the label next do the icon when no values are selected?

The code is:

 <FormControl className={classes.formControl} fullWidth variant="outlined" size="medium">
    <InputLabel name={name} color="secondary" variant="outlined" htmlFor={id} id={id} className={classes.label}>{label}</InputLabel>
    <Select
      name={name}
      labelId={id}
      id={id}
      multiple
      autoWidth
      startAdornment={icon}
      color="secondary"
      value={selectedValues}
      onChange={handleChange}
      renderValue={selectedOptions => (
        <div className={classes.tags}>
          {selectedOptions.map(option => (
            <Chip key={option.value} label={option.label} size="small" className={classes.chipStyle} />
          ))}
        </div>
      )}

    >
      {options.map(option => (

        <MenuItem key={option.value} value={option}>
          <Checkbox checked={logicHere} color="primary" />
          <ListItemText primary={option.label} />
        </MenuItem>
      ))}
    </Select>
  </FormControl>
Hola
  • 329
  • 3
  • 18
  • Side node: the desired behaviour is defined by the [material design itself](https://material.io/components/menus/#exposed-dropdown-menu) - see "Outlined dropdown menu with a leading icon". So, either I do not understand how to use the component properly, or it's a bug – Hola Dec 30 '19 at 21:15
  • Did you wrap `icon` in an `InputAdornment`? In their [demo of text fields](https://material-ui.com/components/text-fields/), they have added an `InputAdornment` component around it – Narigo Jan 22 '20 at 22:00
  • Yes, I tried `startAdornment={ {icon} }` and still the same – Hola Mar 03 '20 at 20:38
  • Its a known bug. The issue for it is here: https://github.com/mui-org/material-ui/issues/13898 – Hola Mar 20 '20 at 18:55

1 Answers1

-1

Did you try ?

<Select 
InputProps={{
    startAdornment: <InputAdornment position="start">Kg</InputAdornment>,
}} />
Dako Junior
  • 587
  • 6
  • 8