Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dc86d5b

Browse files
authoredJul 25, 2020
Merge pull request #595 from topcoder-platform/issue-141
changes for #141
2 parents 0f67320 + 41e0fe3 commit dc86d5b

File tree

1 file changed

+14
-9
lines changed
  • client/src/components/editFiltersPopup

1 file changed

+14
-9
lines changed
 

‎client/src/components/editFiltersPopup/index.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function EditFiltersPopup({ onCancel, onDone }) {
5252
);
5353
const [filterGroups, setFilterGroups] = useState(initialFilters);
5454
const [selectedFilters, setSelectedFilters] = useState(initialSelection);
55-
const [sections, setSections] = useState(initialSections, initialSections);
55+
const [sections, setSections] = useState(initialSections);
5656

5757
const handleCancel = () => {
5858
if (onCancel) {
@@ -108,27 +108,32 @@ export default function EditFiltersPopup({ onCancel, onDone }) {
108108
if (index === -1) {
109109
setSelectedFilters([filter, ...selectedFilters]);
110110
setSearchFilters({
111-
...search.filters,
112-
[filter]: { ...search.filters[filter], active: true },
111+
...searchFilters,
112+
[filter]: { ...searchFilters[filter], active: true },
113113
});
114114
}
115115
} else {
116116
if (index !== -1) {
117117
setSelectedFilters(selectedFilters.filter((_, i) => i !== index));
118118
setSearchFilters({
119-
...search.filters,
120-
[filter]: { ...search.filters[filter], active: false },
119+
...searchFilters,
120+
[filter]: { ...searchFilters[filter], active: false },
121121
});
122122
}
123123
}
124124
};
125125

126126
const handleSearch = (q) => {
127127
if (q.length === 0) {
128-
setFilterGroups(initialFilters);
128+
const [filteredSections, filteredGroups] = getInitialFilters(
129+
searchFilters,
130+
() => true
131+
);
132+
setSections(filteredSections);
133+
setFilterGroups(filteredGroups);
129134
} else if (q.length >= 3) {
130135
const [filteredSections, filteredGroups] = getInitialFilters(
131-
{ ...search.filters },
136+
searchFilters,
132137
(f) => {
133138
return f.text.toLowerCase().includes(q.toLowerCase());
134139
}
@@ -236,10 +241,10 @@ function PopupSection({ title, filters, onFilterValueChange }) {
236241
<>
237242
<PopupSectionTitle text={title} />
238243
<div className={styles.popupSectionBody}>
239-
{filters.map((filter, index) => {
244+
{filters.map((filter) => {
240245
return (
241246
<PopupSectionRow
242-
key={index}
247+
key={filter.id}
243248
text={filter.name}
244249
filterActivated={filter.isActive}
245250
id={filter.id}

0 commit comments

Comments
 (0)
This repository has been archived.