Add event handler on document.click to alert user when navigating away from unsaved work
Description
Closes issues: LA-1484 Related issues:
Add event handler on document click, and check if it hits an <a href=...>
-tag. If so, potentially trigger a confirm dialogue to confirm that the user wishes to navigate away.
Notes to reviewer
After a lot of back and forth, this is a makeshift solution for the bug where users could navigate away from interpretation view without being alerted of unsaved changes. This is certainly not the best way (that would be something like page.js). This is however a simple fix for click-events, but it does not handle popstate events, as I was unable to catch them early enough. I have not done any changes to e2e-tests, to make sure that these dialogues are actually tested.
Type of change
Application (affects UI or general functionality):
-
New feature -
Bug fix -
Improvement
Ops / admin / CI related only (not impacting users):
-
New feature -
Bug fix -
Improvement
Tests
General
-
Tests have been added that prove my fix is effective or that my feature works -
Related tests have been modified/removed
Hypothesis testing:
-
Soak testing has been done -
Distribution between positive / negative cases has been checked
Database
-
Includes changes to database schema -
Includes necessary database migrations
Configuration
-
Includes changes to configuration -
Includes configuration migration instructions in documentation
Merge checklist
-
Self-review of code performed -
Feature review against specification (if applicable) -
Need for documentation has been evaluated and, if necessary, updated -
Code and implementation is reviewed by other core developer (all changes, inc. changes based on initial review)