Skip to content

Commit

Permalink
fixup! refactor(DatePicker): Break up, extract handlers and consolida…
Browse files Browse the repository at this point in the history
…te state
  • Loading branch information
m7kvqbe1 committed Nov 8, 2024
1 parent aa6531c commit 5f0ed87
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const DATEPICKER_ACTION = {

interface ResetAction {
type: typeof DATEPICKER_ACTION.RESET
data: Omit<DatePickerState, 'hasError' | 'inputValue'>
data: Omit<DatePickerState, 'hasError' | 'inputValue' | 'isOpen'>
}

interface UpdateAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function reducer(
): DatePickerState {
switch (action.type) {
case DATEPICKER_ACTION.RESET:
return init(action.data)
return init({ ...action.data, isOpen: state.isOpen })
case DATEPICKER_ACTION.UPDATE:
return { ...state, ...action.data }
case DATEPICKER_ACTION.REFRESH_HAS_ERROR:
Expand Down Expand Up @@ -154,7 +154,6 @@ export function DatePickerProvider({
endDate: endDate ?? null,
currentMonth,
datePickerFormat,
isOpen: initialIsOpen,
calendarTableVariant: CALENDAR_TABLE_VARIANT.HIDE,
},
})
Expand Down

0 comments on commit 5f0ed87

Please sign in to comment.