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

Destroy modals before leaving #101

Merged
merged 1 commit into from
Dec 19, 2024
Merged

Conversation

danieldiekmeier
Copy link
Contributor

The current modal implementation has two bugs. They both surface when you …

  1. Open a modal
  2. Navigate away (e.g. with a link inside the modal)
  3. Go back (e.g. with the browser's back button)

The two bugs are:

  1. Shimmer will add a new .modal-blind every time, making the blind continuously darker
  2. The "close" click handler will not be added again, making it impossible to close the modal

This is in Recordsale when trying to add an album to my wantlist even though I'm not logged in, then clicking the back button:

Screenshot 2024-12-18 at 17 38 48

To solve this, I added code to immediately destroy all open modals. I thought it's probably not worth writing a bunch of code to try and "rehydrate" the modals on back navigation. I also added a check to only contain a new .modal-blind if we don't already have one.


I decided on this way to keep the changes and the chance for breakage minimal. If we want to keep modals open when coming back, I'd say we should maybe migrate modals to Stimulus, so Stimulus can handle all the event handlers for us.

@danieldiekmeier danieldiekmeier self-assigned this Dec 18, 2024
@danieldiekmeier danieldiekmeier added the frontend requires a frontend developer label Dec 18, 2024
@JensRavens JensRavens merged commit ebdc9e4 into main Dec 19, 2024
2 checks passed
@JensRavens JensRavens deleted the destroy-modals-before-leaving branch December 19, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend requires a frontend developer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants