Skip to content

Commit

Permalink
fix: fixed calendar schedule filter output value
Browse files Browse the repository at this point in the history
- fixed issue where the compared indexes for filter were not handled properly, causing the display to be relative to the current day instead of the input filter day
  • Loading branch information
dereekb committed Apr 23, 2023
1 parent b5e041a commit c9b6021
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ export interface CalendarScheduleSelectionState extends PartialCalendarScheduleS
}

export function initialCalendarScheduleSelectionState(): CalendarScheduleSelectionState {
const start = startOfDay(new Date());
const scheduleDays = new Set([DateScheduleDayCode.WEEKDAY, DateScheduleDayCode.WEEKEND]);
const allowedDaysOfWeek = expandDateScheduleDayCodesToDayOfWeekSet(Array.from(scheduleDays));
const start = startOfDay(new Date());
const indexFactory = dateTimingRelativeIndexFactory({ start });
const indexDayOfWeek = dateBlockDayOfWeekFactory(start);

Expand Down Expand Up @@ -408,6 +408,14 @@ export function updateStateWithFilter(state: CalendarScheduleSelectionState, inp

state = { ...state, filter, isEnabledFilterDay };

// If the input filter has a start date, use that as the relative start to ensure indexes are compared the same.
if (filter && filter.start) {
const start = filter.start;
state.start = start;
state.indexFactory = dateTimingRelativeIndexFactory({ start });
state.indexDayOfWeek = dateBlockDayOfWeekFactory(start);
}

// attempt to re-apply the initial selection state once filter is applied
if (state.initialSelectionState) {
state = updateStateWithInitialSelectionState(state, state.initialSelectionState);
Expand Down

0 comments on commit c9b6021

Please sign in to comment.