solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.14k stars 147 forks source link

add delay to useBeforeLeave retry function #462

Closed erwin2848 closed 2 months ago

erwin2848 commented 2 months ago

The useBeforeLeave feature hacks around the fact that u can't prevent browser back/forward navigation, using window.history.go(-1 or 1) to counter the initial direction and go back.

During development I found that window.history.go() can't be called too many times at once or else it doesn't navigate at all.

This behaviour causes a bug when using e.preventDefault() and e.retry(true) together (it changes the url the first time but doesn't render, after this the depth property in the history state is inaccurate and causes further breakage.

Adding a small delay like this would prevent this particular thing from happening.

changeset-bot[bot] commented 2 months ago

🦋 Changeset detected

Latest commit: 1be7cc9a0777c2fa2b65fe41203e54dc66165d01

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | --------------- | ----- | | @solidjs/router | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR