stackworx / formik-mui

Bindings for using Formik with Material-UI
https://stackworx.github.io/formik-mui
MIT License
974 stars 142 forks source link

custom multiple select #227

Open czesuaf92 opened 4 years ago

czesuaf92 commented 4 years ago

Hi i create multiple select with custom styles in dropdown list. image image Is it possible delete from value in input [Object, Object]? Here is my code

const useStyles = makeStyles((theme: Theme) => ({
  multipleMenuItem: {
    position: "relative",
    "& .MuiSvgIcon-root": {
      display: "none",
    },
    "&.Mui-selected .MuiSvgIcon-root": {
      display: "block",
      position: "absolute",
      right: theme.spacing(1),
      color: theme.palette.tint.main,
    },
  },
}));
<Field
          component={TextField}
          type="text"
          name="tags"
          select
          SelectProps={{
            multiple: true,

          }}
          label="Hashtags"
          fullWidth
          variant="outlined"
          margin="normal"
        >
          {tags.map((tag) => (
            <MenuItem
              value={tag.id}
              key={tag.id}
              className={styles.multipleMenuItem}
            >
              {formatTag(tag.name)}
              <CloseIcon />
            </MenuItem>
          ))}
        </Field>
cliedeman commented 3 years ago

@czesuaf92 if you create a codesandbox I can take a look

frankchau93 commented 3 years ago

I get the same issue when I add a checkbox component in the MenuItem component. Seems like it only works if there's no other component inside the MenuItem. @cliedeman try adding a checkbox component inside your menuitem multiple select example and you'll see it.