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

[Reveal] Reveal problem when using deepLink and more nested modal windows #8012

Closed
martinpesout opened this issue Jan 26, 2016 · 8 comments
Closed

Comments

@martinpesout
Copy link

How can we reproduce this bug?

  1. Implement more nested modal windows http://foundation.zurb.com/sites/docs/reveal.html#nested-modal
  2. Enable deepLink for all modals
  3. Try nested modals and try browser "back button" to return to previous state.

What did you expect to happen?

When you go from the first modal window to another, I'd like to see URL with appropriate hash, like #modal-1. But because we have 2 nested modals, new modal will change current URL by https://github.com/zurb/foundation-sites/blob/develop/js/foundation.reveal.js#L277 but previous modal will be closed right after opening. So URL will be changed again by https://github.com/zurb/foundation-sites/blob/develop/js/foundation.reveal.js#L471

Possible solution

My temporary solution is replace this part of code https://github.com/zurb/foundation-sites/blob/develop/js/foundation.reveal.js#L469-L475 with something like this:

    setTimeout(function() {
        if ($('.reveal').filter(':visible').length === 0) {
            if(_this.options.deepLink){
              if(window.history.replaceState){
                window.history.replaceState("", document.title, window.location.pathname);
              }else{
                window.location.hash = '';
              }
            }
        }
    }, 200);

I know that it isn't ideal but it's working for now.

@DanielRuf
Copy link
Contributor

Thanks for reporting this. I guess we have to refctor this a bit to get this case working like it should work.

@DanielRuf
Copy link
Contributor

What do you think @ncoden ? Revisit this for v7?

@ncoden
Copy link
Contributor

ncoden commented Mar 13, 2018

@DanielRuf I don't even understand what the issue is :/

@DanielRuf
Copy link
Contributor

The issue is that nested reveals do not open when you go back in the history like they were opened but in reverse. It stops after the first last reveal.

@DanielRuf
Copy link
Contributor

Try seeing all previously opened reveals by hitting the history.back button.

https://codepen.io/DanielRuf/pen/OvPpzb

@ncoden
Copy link
Contributor

ncoden commented Mar 13, 2018

Ok thanks, it's after modals got closed. I'll take a look at it tomorrow.

@ncoden
Copy link
Contributor

ncoden commented Mar 26, 2018

tomorrow.

Ahah. On it.

ncoden added a commit to ncoden/foundation-sites that referenced this issue Mar 26, 2018
…n#8012

When closing a Reveal with `replaceState: true`, push a new entry to reset the hash. So going back to the history reopen the modals opened before in reverse order.

Closes foundation#8012
ncoden added a commit to ncoden/foundation-sites that referenced this issue Mar 26, 2018
@ncoden
Copy link
Contributor

ncoden commented Mar 26, 2018

See #11093

@ncoden ncoden added the PR open label Mar 26, 2018
ncoden added a commit to ncoden/foundation-sites that referenced this issue Jun 16, 2018
…link-history-8012 for v6.5.0

42d267a fix: update history when closing Reveal with `replaceState` foundation#8012
88c08bd fix: prevent Reveal opening with its hash already set to add history entry
d5fe114 tests: add visual tests for nested Reveal with deep-linking

Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants