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

Stray hash after closing modal #202

Open
acairns opened this issue Dec 1, 2015 · 8 comments
Open

Stray hash after closing modal #202

acairns opened this issue Dec 1, 2015 · 8 comments

Comments

@acairns
Copy link

acairns commented Dec 1, 2015

When a model is closed, a stray hash remains in the URL.

  1. http://example.com/
  2. Open model
  3. http://example.com/#example-modal
  4. Close modal
  5. 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:

  1. http://example.com/#section
  2. Open model
  3. http://example.com/#example-modal
  4. Close modal
  5. http://example.com/#section
@nikmauro
Copy link

The same here. Any suggestion?

@pugson
Copy link

pugson commented Feb 22, 2016

+1

2 similar comments
@jekeyeke
Copy link

+1

@jrosebr1
Copy link

+1

@mistalaba
Copy link

Any news on this? Cheers!

@dornaweb
Copy link

No suggestion?

@pr0jectile
Copy link

pr0jectile commented Sep 8, 2017

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!

@AhmedHdeawy
Copy link

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>

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

9 participants