From 54f53d6ada41118f3ef3e9a459c4e7789055fa2e Mon Sep 17 00:00:00 2001 From: lublagg Date: Wed, 4 Oct 2023 15:50:28 -0400 Subject: [PATCH 1/2] Reset year options when all attributes unselected. --- src/components/years-options.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/years-options.tsx b/src/components/years-options.tsx index 8a9c6d4..16e519e 100644 --- a/src/components/years-options.tsx +++ b/src/components/years-options.tsx @@ -22,6 +22,7 @@ export const YearsOptions: React.FC = (props) => { const selectedAttrKeys = attrKeys.filter((key) => selectedOptions[key].length > 0); if (!selectedAttrKeys.length) { + setAvailableYearOptions([]); return; } From 9b9fe8bbb7b9edb72a9c1ea9920efb7a31bd3a61 Mon Sep 17 00:00:00 2001 From: lublagg Date: Wed, 4 Oct 2023 15:58:49 -0400 Subject: [PATCH 2/2] Sort available years. --- src/components/years-options.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/years-options.tsx b/src/components/years-options.tsx index 16e519e..1b9ec6f 100644 --- a/src/components/years-options.tsx +++ b/src/components/years-options.tsx @@ -38,7 +38,8 @@ export const YearsOptions: React.FC = (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));