foundation / foundation-rails

Foundation for Rails
foundation.zurb.com
MIT License
1k stars 375 forks source link

is-reveal-open and turbolinks #290

Closed haroldus- closed 2 months ago

haroldus- commented 4 years ago

Perhaps there is a way to prevent this behaviour without a custom workaround.

akaspick commented 4 years ago

Same issue here. Destroying or closing the dialog in one of the turbolinks events before navigating away doesn't seem to remove the is-reveal-open class.

My current hack to deal with this is to just manually remove the class:

$(document).on('turbolinks:before-render', function() {
  $('html').removeClass('is-reveal-open')
})
akaspick commented 4 years ago

Well, I had some other issues with the modal not closing properly and now I've settled on the following as a solution that seems to work just fine now:

$(document).on('turbolinks:before-cache', function() {
  if (document.documentElement.classList.contains('is-reveal-open')) {
    $('#dialog').foundation('close')
  }
})
akaspick commented 4 years ago

Noticed more issues when using reveal and turbolinks. If you navigate to a page that uses a reveal modal, and then click back and then forward again via the history, multiple reveal divs are created with the same dom id. Even if you close the modal before navigating away, the multiple reveal divs appear.

I have no current solution for this so far.

jocodeone commented 3 years ago

Any updates on this? It's still an issue using the latest versions for both