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

If a Workflow form receives a redirect response, don't re-enable the submit buttons

Summary:
See PHI488. Ref T13108. Currently, there is a narrow window between when the response returns and when the browser actually follows the redirect where the form is live and you can click the button again.

This is relativey easy if Phabricator is running //too fast// since the button may be disabled only momentarily. This seems to be easier in Firefox/Chrome than Safari.

Test Plan:
  - In Firefox and Chrome, spam-clicked a comment submit button.
    - Before: could sometimes get a double-submit.
    - After: couldn't get a double-submit.
    - This could probably be reproduced more reliabily by adding a `sleep(1)` to whatever we're redirecting //to//.
  - Submitted an empty comment, got a dialog plus a still-enabled form (so this doesn't break the non-redirect case).

Maniphest Tasks: T13108

Differential Revision: https://secure.phabricator.com/D19245
This commit is contained in:
epriestley 2018-03-21 11:42:58 -07:00
parent 6ed123e080
commit 9e278a89ba
2 changed files with 25 additions and 18 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => 'e68cf1fa',
'conpherence.pkg.js' => '15191c65',
'core.pkg.css' => '6da3c0e5',
'core.pkg.js' => '932d60d4',
'core.pkg.js' => 'b305dbe2',
'differential.pkg.css' => '113e692c',
'differential.pkg.js' => 'f6d809c0',
'diffusion.pkg.css' => 'a2d17c7d',
@ -253,7 +253,7 @@ return array(
'rsrc/externals/javelin/lib/URI.js' => 'c989ade3',
'rsrc/externals/javelin/lib/Vector.js' => '2caa8fb8',
'rsrc/externals/javelin/lib/WebSocket.js' => '3ffe32d6',
'rsrc/externals/javelin/lib/Workflow.js' => '0eb1db0c',
'rsrc/externals/javelin/lib/Workflow.js' => '33fea02f',
'rsrc/externals/javelin/lib/__tests__/Cookie.js' => '5ed109e8',
'rsrc/externals/javelin/lib/__tests__/DOM.js' => 'c984504b',
'rsrc/externals/javelin/lib/__tests__/JSON.js' => '837a7d68',
@ -739,7 +739,7 @@ return array(
'javelin-workboard-card' => 'c587b80f',
'javelin-workboard-column' => '758b4758',
'javelin-workboard-controller' => '26167537',
'javelin-workflow' => '0eb1db0c',
'javelin-workflow' => '33fea02f',
'maniphest-report-css' => '9b9580b7',
'maniphest-task-edit-css' => 'fda62a9b',
'maniphest-task-summary-css' => '11cc5344',
@ -960,17 +960,6 @@ return array(
'javelin-dom',
'javelin-router',
),
'0eb1db0c' => array(
'javelin-stratcom',
'javelin-request',
'javelin-dom',
'javelin-vector',
'javelin-install',
'javelin-util',
'javelin-mask',
'javelin-uri',
'javelin-routable',
),
'0f764c35' => array(
'javelin-install',
'javelin-util',
@ -1108,6 +1097,17 @@ return array(
'javelin-util',
'javelin-magical-init',
),
'33fea02f' => array(
'javelin-stratcom',
'javelin-request',
'javelin-dom',
'javelin-vector',
'javelin-install',
'javelin-util',
'javelin-mask',
'javelin-uri',
'javelin-routable',
),
'358b8c04' => array(
'javelin-install',
'javelin-util',

View file

@ -59,12 +59,15 @@ JX.install('Workflow', {
workflow.setDataWithListOfPairs(pairs);
workflow.setMethod(form.getAttribute('method'));
workflow.listen('finally', function() {
// Re-enable form elements
for (var ii = 0; ii < inputs.length; ii++) {
inputs[ii] && (inputs[ii].disabled = false);
var onfinally = JX.bind(workflow, function() {
if (!this._keepControlsDisabled) {
for (var ii = 0; ii < inputs.length; ii++) {
inputs[ii] && (inputs[ii].disabled = false);
}
}
});
workflow.listen('finally', onfinally);
return workflow;
},
@ -242,6 +245,7 @@ JX.install('Workflow', {
_form: null,
_paused: 0,
_nextCallback: null,
_keepControlsDisabled: false,
getSourceForm: function() {
return this._form;
@ -283,6 +287,9 @@ JX.install('Workflow', {
this._pop();
}
// If we're redirecting, don't re-enable for controls.
this._keepControlsDisabled = true;
JX.$U(r.redirect).go();
} else if (r && r.dialog) {
this._push();