Skip to content

Commit

Permalink
fixed the browser back button not woking
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijeetsingh-22 committed Jan 20, 2024
1 parent 95e037c commit 8b475bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/features/bookings/Booker/utils/query-param.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export const updateQueryParam = (param: string, value: string | number) => {
} else {
url.searchParams.set(param, `${value}`);
}

window.history.pushState({}, "", url.href);
window.history.replaceState(window.history.state, "", url.href);
};

export const getQueryParam = (param: string) => {
Expand All @@ -22,5 +21,5 @@ export const removeQueryParam = (param: string) => {

const url = new URL(window.location.href);
url.searchParams.delete(param);
window.history.pushState({}, "", url.href);
window.history.replaceState(window.history.state, "", url.href);
};
7 changes: 6 additions & 1 deletion packages/features/calendars/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,15 @@ const Days = ({
// If selected date not available in the month, select the first available date of the month
props.onChange(firstAvailableDateOfTheMonth);
}

if (isSelectedDateAvailable) {
props.onChange(dayjs(selected));
}
if (!firstAvailableDateOfTheMonth) {
props.onChange(null);
}
return () => {
props.onChange(null);
};
};

useEffect(useHandleInitialDateSelection);
Expand Down

0 comments on commit 8b475bc

Please sign in to comment.