1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

Show confirmation dialog when closing a modal if form contents have been changed

Summary: Honestly I did not realize that Differential can do this. Anyway this is related to T15034 ... Originally opened at https://secure.phabricator.com/T12676

Test Plan:
1) Start creating a task via a Workboard in Manifest, type many words, press `ESC`

2) Start creating a task via a Workboard in Manifest, type no words, press `ESC`

Reviewers: O1 Blessed Committers, Ekubischta, speck

Reviewed By: O1 Blessed Committers, Ekubischta, speck

Subscribers: Leon95, 20after4, avivey, Ekubischta, speck, tobiaswiese

Tags: #maniphest

Differential Revision: https://we.phorge.it/D25015
This commit is contained in:
Matthew Bowker 2022-09-21 11:25:51 -06:00
parent 377ac059d6
commit a16e8773f0

View file

@ -403,6 +403,16 @@ JX.install('Workflow', {
JX.$E('Response to workflow request went unhandled.'); JX.$E('Response to workflow request went unhandled.');
} }
} }
var form = JX.DOM.scry(this._root, 'form', 'jx-dialog');
if (form.length) {
JX.DOM.listen(form[0], 'keydown', null, function(e) {
if (e.getSpecialKey()) {
return;
}
JX.Stratcom.addSigil(form[0], 'dialog-keydown');
});
}
}, },
_push : function() { _push : function() {
if (!this._pushed) { if (!this._pushed) {
@ -536,6 +546,15 @@ JX.install('Workflow', {
return; return;
} }
var form = JX.DOM.scry(active._root, 'form', 'jx-dialog');
if (
form.length &&
JX.Stratcom.hasSigil(form[0], 'dialog-keydown') &&
!confirm('Form data may have changed. Are you sure you want to close this dialog?')
) {
return;
}
JX.Workflow._pop(); JX.Workflow._pop();
e.prevent(); e.prevent();
} }