Skip to content

Commit

Permalink
Add special case when it's the last value
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Jun 15, 2023
1 parent 5160c41 commit 621be65
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 deletions searchlib/components/FilterList/ActiveFilterValue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ const ActiveFilterValue = (props) => {
name="close"
tabIndex={0}
onClick={() => {
removeFilter(field, null, type || filterConfig.filterType);
if (values.length === 1) {
removeFilter(field, null, type || filterConfig.filterType);
} else {
removeFilter(field, value, type || filterConfig.filterType);
}
}}
onKeyDown={(e) => {
if (e.key === 'Enter') {
removeFilter(field, null, type || filterConfig.filterType);
if (values.length === 1) {
removeFilter(field, null, type || filterConfig.filterType);
} else {
removeFilter(field, value, type || filterConfig.filterType);
}
}
}}
/>
Expand Down
8 changes: 8 additions & 0 deletions searchlib/components/SearchApp/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ export function removeFilter(name, value, type) {
}
} else if (value) {
updatedFilters = removeSingleFilterValue(filters, name, value, type);
// console.log('updated', {
// name,
// value,
// type,
// updatedFilters,
// filter,
// filters,
// });
} else {
if (filter.missing) {
updatedFilters = [
Expand Down

0 comments on commit 621be65

Please sign in to comment.