Remodal
Remodal copied to clipboard
Stray hash after closing modal
When a model is closed, a stray hash remains in the URL.
- http://example.com/
- Open model
- http://example.com/#example-modal
- Close modal
- http://example.com/#
This can be easily worked around by listening for a close event an using replaceState - however I don't thing it's expected behaviour. In fact, I would expect the URL to return to what it was perviously - if the hash is already populated, the last state should return:
- http://example.com/#section
- Open model
- http://example.com/#example-modal
- Close modal
- http://example.com/#section
The same here. Any suggestion?
+1
+1
+1
Any news on this? Cheers!
No suggestion?
I've found a way to fix this problem.
In remodal.js find
location.hash = '';
then add the following code underneath it
history.replaceState({}, document.title, location.href.replace('#', ''));
so you should have
location.hash = '';
history.replaceState({}, document.title, location.href.replace('#', ''));
$(window).scrollTop(scrollTop);
This clears # from the URL upon closing the popup via the wrapper and buttons as well as replaces the stray hash URL in the browser history buttons.
Hope this helps!
you can add this to Modal wrap [ data-remodal-options="hashTracking: false," ] finally, your modal will like this
<div class="remodal remodal-date" data-remodal-id="modal2" data-remodal-options="hashTracking: false,">
<button data-remodal-action="close" class="remodal-close"></button>
<h1>Chage Order Date</h1>
<p>
</p>
<br>
<button data-remodal-action="cancel" class="remodal-cancel">Cancel</button>
</form>
</div>