From 29ad6bd9fecb276b204751d822f85d2eb5bac4ab Mon Sep 17 00:00:00 2001 From: PolariTOON <36267812+PolariTOON@users.noreply.github.com> Date: Wed, 28 Sep 2022 17:05:26 +0200 Subject: [PATCH] fix: Make `SelectDates` accept values without months This avoids rerendering with the wrong month when navigating from a category to a subcategory while "All year" is checked. --- src/components/SelectDates/SelectDates.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/SelectDates/SelectDates.jsx b/src/components/SelectDates/SelectDates.jsx index 456045c32c..ae06f23276 100644 --- a/src/components/SelectDates/SelectDates.jsx +++ b/src/components/SelectDates/SelectDates.jsx @@ -22,8 +22,6 @@ import Select from 'components/Select' import { rangedSome } from 'components/SelectDates/utils' import { themed } from 'components/useTheme' -const isAllYear = value => value && value.includes('allyear') - const getOptionValue = option => option.value const capitalizeFirstLetter = string => { return string.charAt(0).toUpperCase() + string.slice(1) @@ -115,6 +113,8 @@ class SelectDateButton extends PureComponent { } const isFullYearValue = value => value && value.length === 4 +const isAllYear = value => + value && (isFullYearValue(value) || value.includes('allyear')) const isOptionEnabled = option => option && !option.isDisabled const allDisabledFrom = (options, maxIndex) => { return !rangedSome(options, isOptionEnabled, maxIndex, -1) @@ -215,7 +215,7 @@ class SelectDates extends PureComponent { value = nearest.value } } - if (value && value.includes('allyear')) { + if (allyear) { value = value.substr(0, 4) }