Warn in Web Editor when user navigates away
Problem to solve
It is a common mistake to click on a link or bookmark while editing a file in the GitLab Web Editor. The changes are irrevocably lost.
Proposal
The GitLab WebIDE displays a dialog in such a case, which warns against leaving the page. I propose to implement this behavior for the GitLab Web Editor as well.
See commit 4154477c.
What does success look like, and how can we measure that?
Add this JavaScript to the Web Editor page:
window.addEventListener('beforeunload', function (e) { e.preventDefault(); e.returnValue = ''; });
For testing you can use the debug console of your Web Browser as shown in the image.
Then click on a link or bookmark and your browser will warn you: