Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: browser back button not working #13345

Merged
merged 29 commits into from Apr 22, 2024

Conversation

abhijeetsingh-22
Copy link
Contributor

What does this PR do?

Fixes a bug due to which the back button on the booking page was not working.
The issue was due to multiple calls to setQueryParams and removeQueryParams as it was pushing multiple URLs to the browser history.

My fix

Instead of pushing to the history I am now replacing the last entry in the history.

Fixes #13324

Calcom.Back.button.fix.mp4

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

  • Go to the booking page of a user with multiple events present.
  • Open one of the events and change the date selected.
  • Press the browser back button (You should be taken back to the user page.)
  • Try repeating this with the other event .

Mandatory Tasks

  • [ x] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Copy link

vercel bot commented Jan 20, 2024

@abhijeetsingh-22 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

github-actions bot commented Jan 20, 2024

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

Copy link
Contributor

github-actions bot commented Jan 20, 2024

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@keithwillcode keithwillcode added this to the v3.8 milestone Jan 21, 2024
@keithwillcode keithwillcode added Medium priority Created by Linear-GitHub Sync booking-page area: booking page, public booking page, booker community Created by Linear-GitHub Sync labels Jan 21, 2024
@keithwillcode keithwillcode requested a review from a team January 21, 2024 12:04
@PeerRich PeerRich added High priority Created by Linear-GitHub Sync and removed Medium priority Created by Linear-GitHub Sync labels Jan 21, 2024
Copy link

vercel bot commented Jan 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2024 7:56am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2024 7:56am

@PeerRich PeerRich added ⚡ Quick Wins A collection of quick wins/quick fixes that are less than 30 minutes of work 📉 regressing This used to work. Now it doesn't anymore. labels Jan 21, 2024
Copy link
Contributor

@Udit-takkar Udit-takkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen.Recording.2024-01-22.at.2.31.28.PM.mov

I should be back to the booking form page and not /[user]

@emrysal
Copy link
Contributor

emrysal commented Jan 22, 2024

@abhijeetsingh-22 looks like Udit is right; not an issue with your PR but it looks like the history is not set properly (perhaps due to next router) when coming from the booking page?

@github-actions github-actions bot added the Medium priority Created by Linear-GitHub Sync label Jan 22, 2024
@abhijeetsingh-22
Copy link
Contributor Author

@abhijeetsingh-22 looks like Udit is right; not an issue with your PR but it looks like the history is not set properly (perhaps due to next router) when coming from the booking page?

@emrysal The problem is not the next-router but the way we are handling the queryParams in the /[user]/[type] . I have made the changes have a look

Kapture.2024-01-23.at.04.26.14.mp4

@github-actions github-actions bot added the 🚨 merge conflict This PR has a merge conflict that has to be addressed label Jan 23, 2024
@@ -213,6 +213,10 @@ const BookerComponent = ({
return setBookerState("booking");
}, [event, selectedDate, selectedTimeslot, setBookerState]);

const slot = getQueryParam("slot");
useEffect(() => {
setSelectedTimeslot(slot || null);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sure that the selectedTimeslot updates in the store when it is changed in the query param. And it sets it to null when the slot query param is not present

} else {
url.searchParams.set(param, `${value}`);
}

window.history.pushState({}, "", url.href);
if (param == "slot") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the desired behavior, we need to smartly choose between pushState and replaceState so that the browser history is created the way we want. This is in-line with the change that @Udit-takkar requested earlier.

Copy link
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes cause booking-limits e2e tests to fail.

I found one issue that happens in https://github.com/calcom/cal.com/blob/main/apps/web/playwright/booking-limits.e2e.ts#L306. For monthly duration limits, it doesn't redirect to the booking page but stays on the availability page instead

@abhijeetsingh-22
Copy link
Contributor Author

I will look into it

@keithwillcode keithwillcode marked this pull request as draft March 7, 2024 12:48
auto-merge was automatically disabled March 7, 2024 12:48

Pull request was converted to draft

@CarinaWolli CarinaWolli modified the milestones: v3.9, v4.0 Mar 18, 2024
@keithwillcode keithwillcode modified the milestones: v4.0, v4.1 Apr 15, 2024
@dosubot dosubot bot removed this from the v4.1 milestone Apr 15, 2024
@keithwillcode keithwillcode added this to the v4.1 milestone Apr 16, 2024
@github-actions github-actions bot added the 💎 Bounty A bounty on Algora.io label Apr 17, 2024
@Udit-takkar Udit-takkar marked this pull request as ready for review April 18, 2024 19:50
@dosubot dosubot bot added the 🐛 bug Something isn't working label Apr 18, 2024
@CarinaWolli CarinaWolli merged commit 9215725 into calcom:main Apr 22, 2024
30 of 38 checks passed
Copy link

algora-pbc bot commented Apr 22, 2024

🎉🎈 @abhijeetsingh-22 has been awarded $20! 🎈🎊

@algora-pbc algora-pbc bot added the 💰 Rewarded Rewarded bounties on Algora.io label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
booking-page area: booking page, public booking page, booker 💎 Bounty A bounty on Algora.io 🐛 bug Something isn't working community Created by Linear-GitHub Sync High priority Created by Linear-GitHub Sync Medium priority Created by Linear-GitHub Sync ⚡ Quick Wins A collection of quick wins/quick fixes that are less than 30 minutes of work 📉 regressing This used to work. Now it doesn't anymore. 💰 Rewarded Rewarded bounties on Algora.io
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAL-2972] Back button on the booking page is not working properly
9 participants