Reimplement warning prompt with wouter#874
Merged
Merged
Conversation
loichuder
commented
Jun 29, 2026
Comment on lines
+21
to
+25
| useEventListener(window, 'beforeunload', (event: BeforeUnloadEvent) => { | ||
| if (displayWarning) { | ||
| event.preventDefault(); | ||
| } | ||
| }); |
Member
Author
There was a problem hiding this comment.
This is for external navigation so same as https://github.com/ewoks-kit/ewoksweb/pull/789/changes
Comment on lines
+27
to
+43
| return [ | ||
| location, | ||
| (newLocation, options) => { | ||
| if (!displayWarning) { | ||
| setLocation(newLocation, options); | ||
| return; | ||
| } | ||
| // eslint-disable-next-line no-alert | ||
| const perfomNavigation = window.confirm( | ||
| 'There are unsaved changes that will be lost when navigating to another page. Do you want to continue?', | ||
| ); | ||
|
|
||
| if (perfomNavigation) { | ||
| setLocation(newLocation, options); | ||
| } | ||
| }, | ||
| ]; |
Member
Author
There was a problem hiding this comment.
For inner navigation
Inspired by molefrog/wouter#39 but without the specific context since on our case, the workflow store already acts as the context
axelboc
approved these changes
Jun 29, 2026
bf3c82d to
3bc7ff1
Compare
437651c to
8513a51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#873 (comment)
I struggled to reach the solution but in the end it is not so bad.
The only difference is that the hook needs to be implemented at the
Routerlevel since it needs to intercept any call tonavigate. It results in an additional condition to check the location compared to thereact-routerimplementation.We can work on the session storage next and perhaps remove the internal navigation warning.