Skip to content

Commit fa9e0b0

Browse files
authored
fix: preserve date picker state when switching back from unlimited (#1904)
When switching to unlimited and back to an accrual method, the custom reset date picker wasn't showing because the useEffect aggressively cleared resetDateType. Now the effect returns early for unlimited, preserving form state so the date picker restores on switch-back.
1 parent 962b8a4 commit fa9e0b0

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ export function PolicyConfigurationFormPresentation({
7878
}, [resetMonth, getValues, setValue])
7979

8080
useEffect(() => {
81+
if (accrualMethod === 'unlimited') {
82+
return
83+
}
8184
if (accrualMethod !== 'per_hour_paid') {
8285
setValue('accrualRateUnit', undefined)
8386
setValue('includeOvertime', undefined)
@@ -86,12 +89,6 @@ export function PolicyConfigurationFormPresentation({
8689
if (accrualMethod !== 'per_calendar_year') {
8790
setValue('accrualMethodFixed', undefined)
8891
}
89-
if (accrualMethod !== 'per_hour_paid' && accrualMethod !== 'per_calendar_year') {
90-
setValue('resetDateType', undefined)
91-
setValue('resetMonth', 1)
92-
setValue('resetDay', 1)
93-
setValue('accrualRate', undefined)
94-
}
9592
}, [accrualMethod, setValue])
9693

9794
const handleResetDateTypeChange = useCallback(

0 commit comments

Comments
 (0)