I have following code, and I hope you can help me to resolve my issue.
The code:
import React from "react";
import { Select } from "antd";
const { Option } = Select;
const data = [
{ id: 55, name: "Appraisals" },
{ id: 65, name: "Carpet Cleaning" },
{ id: 53, name: "Duct cleaning & antibacterial" },
{ id: 54, name: "Electrical" },
{ id: 62, name: "Handyman Services" },
{ id: 68, name: "Home Cleaning Services" }
];
const App = () => (
<Select
mode="tags"
style={{
width: "100%"
}}
showSearch={false}
>
<Option value={null}>All</Option>
{data?.map((el) => (
<Option key={el?.id} value={el?.id}>
{el?.name}
</Option>
))}
</Select>
);
export default App;
The scenario is following.
The user can select multiple options. But when the user selects "All", all the selected tags should be removed and only the "All" tag should be left.
Conversely, when the user selects "All" and then the user selects another option, "All" should removed and only the selected options should be left.
I tried to do something with onSelect and with onChange events. But they taking only current value.
How Can I achieve this result?... Please help me to resolve this problem. Thanks.