Skip to content

Commit

Permalink
Merge pull request #11 from concord-consortium/185951219-bug-fixes
Browse files Browse the repository at this point in the history
Reset years when all attributes are unselected. (PT-185951219)
  • Loading branch information
lublagg authored Oct 5, 2023
2 parents fd28975 + 9b9fe8b commit 6c4b066
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/years-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const YearsOptions: React.FC<IProps> = (props) => {
const selectedAttrKeys = attrKeys.filter((key) => selectedOptions[key].length > 0);

if (!selectedAttrKeys.length) {
setAvailableYearOptions([]);
return;
}

Expand All @@ -37,7 +38,8 @@ export const YearsOptions: React.FC<IProps> = (props) => {
return years;
}, new Set());
const newSet: string[] = Array.from(newAvailableYears);
setAvailableYearOptions(newSet);
const sorted = newSet.sort().reverse();
setAvailableYearOptions(sorted);

// if selected years includes years not in available options, remove them from selection
const selectionsNotAvailable = selectedOptions.years.filter(year => !newSet.includes(year));
Expand Down

0 comments on commit 6c4b066

Please sign in to comment.