Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

race condition on load with modal open #144

Open
eyston opened this issue Jun 26, 2013 · 0 comments
Open

race condition on load with modal open #144

eyston opened this issue Jun 26, 2013 · 0 comments

Comments

@eyston
Copy link

eyston commented Jun 26, 2013

If you refresh a page with the modal open sometimes it works, sometimes the modal flashes open and instantly closes leaving the url in a wrong state.

The issue is in bwa.js line 39 and 99.

The popstate event fires in chrome on the first load with an ev.state of null. This would set lightbox to null which results in the modal being closed.

The success handler for the get request on project.json also updates lightbox checking if a project matches the current url. If there is a match it sets the lightbox to the project which results in the modal being open.

What I think happens is that the project.json file request finishes first and sets the lightbox to the project which has the modal begin to open. Then the onpopstate event handler fires which immediately closes the modal leaving the url in a wrong state. Using the chrome debugger with breakpoints on 39 and 99 seems to confirm this (if 99 is first, it breaks).

Looking at this stack overflow post (http://stackoverflow.com/questions/6421769/popstate-on-pages-load-in-chrome) it seems like checking if ev.state === null and ignoring that popstate event if so might work, but I'm not sure if that is fully cross browser or would ignore legit events (I've never used the popstate event so don't really know whats valid or not).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant