Skip to content

Commit

Permalink
fix: Make SelectDates accept values without months
Browse files Browse the repository at this point in the history
This avoids rerendering with the wrong month when navigating from a category to a subcategory while "All year" is checked.
  • Loading branch information
PolariTOON committed Sep 28, 2022
1 parent 5772bfe commit 29ad6bd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/SelectDates/SelectDates.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -215,7 +215,7 @@ class SelectDates extends PureComponent {
value = nearest.value
}
}
if (value && value.includes('allyear')) {
if (allyear) {
value = value.substr(0, 4)
}

Expand Down

0 comments on commit 29ad6bd

Please sign in to comment.