Skip to content

Commit

Permalink
Merge pull request #2337 from zetkin/issue-2330/smart-search-gender-d…
Browse files Browse the repository at this point in the history
…efault-value

Set or clear value when switching to/from gender filter
  • Loading branch information
richardolsson authored Nov 12, 2024
2 parents 7485949 + 9e7d2d6 commit 970b725
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/features/smartSearch/components/filters/PersonData/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,20 @@ const PersonData = ({
if (field === REMOVE_FIELD) {
setCriteria(criteria.filter((criterion) => criterion.field !== c.field));
} else {
let value = c.value;
// Default value for gender is 'f'
if (field === DATA_FIELD.GENDER) {
value = 'f';
}

// It doesn't make sense to use the gender value when changing to other fields
if (c.field === DATA_FIELD.GENDER) {
value = '';
}
setCriteria(
criteria.map((criterion) => {
return criterion.field === c.field
? { ...criterion, field: field as DATA_FIELD }
? { field: field as DATA_FIELD, value }
: criterion;
})
);
Expand Down

0 comments on commit 970b725

Please sign in to comment.