Skip to content

Commit e1c4440

Browse files
authored
fix(extensions): fix issue with deselecting the selected filter (#668)
1 parent d3b7841 commit e1c4440

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-marketplace': patch
3+
---
4+
5+
fix issue with deselecting the selected filter

workspaces/marketplace/plugins/marketplace/src/components/MarketplacePluginFilter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const AuthorFilter = () => {
7373

7474
const handleChange = React.useCallback(
7575
(_e: any, value: SelectItem[]) => {
76-
const newSelection = value.map(v => v.value);
76+
const newSelection = value.map(v => v.label);
7777
filter.set(newSelection);
7878
},
7979
[filter],

workspaces/marketplace/plugins/marketplace/src/hooks/useQueryArrayFilter.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ const evaluateParams = (
2525
newParams: URLSearchParams,
2626
filterName: string,
2727
) => {
28-
if (Array.isArray(newValues)) {
29-
newValues.forEach(v => {
30-
newParams.append(filterSearchParam, `${filterName}=${v}`);
31-
});
32-
} else {
33-
newParams.append(filterSearchParam, `${filterName}=${newValues}`);
34-
}
28+
newValues.forEach(v => {
29+
newParams.append(filterSearchParam, `${filterName}=${v}`);
30+
});
3531
};
3632

3733
export const useQueryArrayFilter = (filterName: string) => {

workspaces/marketplace/plugins/marketplace/src/shared-components/CustomSelectFilter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const CustomSelectFilter = (props: BackstageSelectFilterProps) => {
6060
disableCloseOnSelect
6161
aria-label={props.label}
6262
options={props.items}
63+
isOptionEqualToValue={(option, value) => option.value === value.value}
6364
getOptionLabel={option => option.label}
6465
onChange={props.onChange}
6566
renderOption={(renderProps, option, selectedOption) => {
@@ -72,7 +73,7 @@ export const CustomSelectFilter = (props: BackstageSelectFilterProps) => {
7273
style={{ marginRight: 8 }}
7374
checked={
7475
props.selectedItems.find(
75-
c => c.value === option.value.toString(),
76+
c => c.label === option.label.toString(),
7677
)
7778
? true
7879
: selectedOption.selected

0 commit comments

Comments
 (0)