Skip to content

Commit 20d6272

Browse files
fix: 🐛 filter selection (#475)
1 parent 9aeac87 commit 20d6272

File tree

4 files changed

+3
-7
lines changed

4 files changed

+3
-7
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ More examples can be found [here ↗](./docs/recipes)
7070
| `overrideStrings` | [localization ↗](docs/recipes/localization.md) | `object` | |
7171
| `onChange` | onChange callback | `function` | |
7272
| `disabled` | disable dropdown | `boolean` | `false` |
73-
| `selectAllLabel` | _select all_ label | `string` | |
7473
| `disableSearch` | hide search textbox | `boolean` | `false` |
7574
| `filterOptions` | [custom filter options (async supported) ↗](docs/recipes/custom-filter.md) | `function` | Fuzzy Search |
7675
| `className` | class name for parent component | `string` | `multi-select` |

src/hooks/use-multi-select.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const defaultStrings = {
1010
noOptions: "No options",
1111
search: "Search",
1212
selectAll: "Select All",
13+
selectAllFiltered: "Select All (Filtered)",
1314
selectSomeItems: "Select...",
1415
create: "Create",
1516
};

src/lib/interfaces.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export interface ISelectProps {
1414
valueRenderer?: (selected: Option[], options: Option[]) => ReactNode;
1515
ItemRenderer?;
1616
ArrowRenderer?: ({ expanded }) => JSX.Element;
17-
selectAllLabel?: string;
1817
isLoading?: boolean;
1918
disabled?: boolean;
2019
disableSearch?: boolean;

src/select-panel/index.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const SelectPanel = () => {
3333
setOptions,
3434
value,
3535
filterOptions: customFilterOptions,
36-
selectAllLabel,
3736
ItemRenderer,
3837
disabled,
3938
disableSearch,
@@ -65,7 +64,7 @@ const SelectPanel = () => {
6564
}, [disableSearch, hasSelectAll]);
6665

6766
const selectAllOption = {
68-
label: selectAllLabel || t("selectAll"),
67+
label: searchText ? t("selectAllFiltered") : t("selectAll"),
6968
value: "",
7069
};
7170

@@ -78,9 +77,7 @@ const SelectPanel = () => {
7877
const selectedValues = value.map((o) => o.value);
7978
const finalSelectedValues = [...selectedValues, ...filteredValues];
8079

81-
return filteredOptions.filter((o) =>
82-
finalSelectedValues.includes(o.value)
83-
);
80+
return options.filter((o) => finalSelectedValues.includes(o.value));
8481
}
8582

8683
return value.filter((o) => !filteredValues.includes(o.value));

0 commit comments

Comments
 (0)