This is a bit like T15034 but related to:
- you click a link by mistake
- you close the tab by mistake
- you close the browser by mistake
In short, maybe there is a way to listen to some events, like these probably:
- onblur
This is not related just to Maniphest, but surely Maniphest is the core component involved in this, since it's easy to lose your work on a Task description if you click on a nearby link by mistake.
Also, note that the back button of your browser may not be able to recover your Task description, most of the times (or maybe just lising it all the times).
== Minimal cross-browser JavaScript ==
https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
https://developer.mozilla.org/en-US/docs/Web/API/BeforeUnloadEvent
```lang=javascript
function areThereUnsavedChanges() {
return true; // override me
}
/*
* Ask for confirmation when you are closing your tab
*
* https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
*/
function onBeforeUnload(e) {
if (areThereUnsavedChanges()) {
// For security reasons, only a generic string not under the control
// of the webpage is shown instead of this returned string
// so you can put here whatever you want
// https://developer.mozilla.org/en-US/docs/Web/API/BeforeUnloadEvent
var confirmationMessage = "\\o/";
// Gecko + IE
(e || window.event).returnValue = confirmationMessage;
// Safari, Chrome, and other WebKit-derived browsers
return confirmationMessage;
}
}
window.addEventListener('beforeunload', onBeforeUnload);
```
Bonus points:
- don't register multiple similar listeners
- activate this listener only when there is at least one change
- remove this listener if the thing is then saved (important only if it's an Ajax action)