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

[material-ui][Chip] onDelete function not called on Chip present inside Multiselect #38463

Closed
1 task done
zee0786 opened this issue Aug 14, 2023 · 1 comment
Closed
1 task done
Labels
component: chip This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists package: material-ui Specific to @mui/material

Comments

@zee0786
Copy link

zee0786 commented Aug 14, 2023

Duplicates

  • I have searched the existing issues

Related page

https://mui.com/material-ui/react-select/

Kind of issue

Broken demonstration

Issue description

I was looking for a chip that can be implemented using multi select and it appears that is able to represent them though but unable to delete them using the onDelete functionality provided as props on the Chip.

Here goes the code below

import React, { useState } from 'react';
import { Select, MenuItem, Chip } from '@mui/material';

const MySelect = () => {
  const [selectedValues, setSelectedValues] = useState([]);

  const handleDelete = (value) => { // Not called
    setSelectedValues((prevValues) => prevValues.filter((item) => item !== value));
  };

  const handleChange = (event) => {
    setSelectedValues(event.target.value);
  };

  return (
    <Select
      multiple
      value={selectedValues}
      onChange={handleChange}
      renderValue={(selected) => (
        <div>
          {selected.map((value) => (
            <Chip key={value} label={value} onDelete={() => handleDelete(value)} />
          ))}
        </div>
      )}
    >
      {['Option 1', 'Option 2', 'Option 3'].map((option) => (
        <MenuItem key={option} value={option}>
          {option}
        </MenuItem>
      ))}
    </Select>
  );
};

export default MySelect;

Context 🔦

I was searching for an onDelete functionality on the multiSelect Chip using renderValue Props

@zee0786 zee0786 added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: docs-feedback Feedback from documentation page labels Aug 14, 2023
@zannager zannager added the component: chip This is the name of the generic UI component, not the React module! label Aug 14, 2023
@mapache-salvaje mapache-salvaje changed the title onDelete fuinction not called on Chip present inside multiselect [material-ui][Chip] onDelete function not called on Chip present inside Multiselect Sep 5, 2023
@ZeeshanTamboli
Copy link
Member

@zee0786 This is a duplicated of multiple issues - #35488, #27614, #21378, #18658.

@ZeeshanTamboli ZeeshanTamboli closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2023
@ZeeshanTamboli ZeeshanTamboli added duplicate This issue or pull request already exists package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: docs-feedback Feedback from documentation page labels Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: chip This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists package: material-ui Specific to @mui/material
Projects
None yet
Development

No branches or pull requests

4 participants