mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-03 11:21:01 +01:00
Fix submitting forms in a new tab using Ctrl+Return
Summary: This commit adds a keydown listener to <input> elements to activate a flag when Ctrl (and other keys) are pressed, which causes forms to be submitted to a new tab. This commit also modifies the click event listener for buttons to ignore synthetic clicks from the browser, which is important as they clobber the "new_tab" flag otherwise. Closes T15914 Test Plan: Open the Advanced Search form, and do Ctrl+Return inside one of the text boxes to ensure that the result is opened in a new tab. Also do a plain Return, plain click on "Search", and Ctrl+Click on Search to check for regressions. Reviewers: O1 Blessed Committers, valerio.bozzolan, aklapper Reviewed By: O1 Blessed Committers, valerio.bozzolan, aklapper Subscribers: aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15914 Differential Revision: https://we.phorge.it/D25773
This commit is contained in:
parent
a76444a8e2
commit
0ea95d41a6
2 changed files with 26 additions and 9 deletions
|
@ -10,7 +10,7 @@ return array(
|
|||
'conpherence.pkg.css' => '2f25eb4f',
|
||||
'conpherence.pkg.js' => '020aebcf',
|
||||
'core.pkg.css' => 'ac619266',
|
||||
'core.pkg.js' => '2eeda9e0',
|
||||
'core.pkg.js' => '8c86adab',
|
||||
'dark-console.pkg.js' => '187792c2',
|
||||
'differential.pkg.css' => '94bb10ca',
|
||||
'differential.pkg.js' => '46fcb3af',
|
||||
|
@ -476,7 +476,7 @@ return array(
|
|||
'rsrc/js/core/behavior-device.js' => 'ac2b1e01',
|
||||
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6bc7ccf7',
|
||||
'rsrc/js/core/behavior-fancy-datepicker.js' => 'b545d0a0',
|
||||
'rsrc/js/core/behavior-form.js' => '55d7b788',
|
||||
'rsrc/js/core/behavior-form.js' => 'c60fb44a',
|
||||
'rsrc/js/core/behavior-gesture.js' => 'b58d1a2a',
|
||||
'rsrc/js/core/behavior-global-drag-and-drop.js' => '1cab0e9a',
|
||||
'rsrc/js/core/behavior-high-security-warning.js' => 'dae2d55b',
|
||||
|
@ -591,7 +591,7 @@ return array(
|
|||
'javelin-behavior-aphlict-status' => 'c3703a16',
|
||||
'javelin-behavior-aphront-basic-tokenizer' => '3b4899b0',
|
||||
'javelin-behavior-aphront-drag-and-drop-textarea' => '6bc7ccf7',
|
||||
'javelin-behavior-aphront-form-disable-on-submit' => '55d7b788',
|
||||
'javelin-behavior-aphront-form-disable-on-submit' => 'c60fb44a',
|
||||
'javelin-behavior-aphront-more' => '506aa3f4',
|
||||
'javelin-behavior-audio-source' => '3dc5ad43',
|
||||
'javelin-behavior-audit-preview' => 'b7b73831',
|
||||
|
@ -1432,11 +1432,6 @@ return array(
|
|||
'javelin-install',
|
||||
'javelin-dom',
|
||||
),
|
||||
'55d7b788' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
),
|
||||
'5793d835' => array(
|
||||
'javelin-install',
|
||||
'javelin-util',
|
||||
|
@ -2034,6 +2029,11 @@ return array(
|
|||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
),
|
||||
'c60fb44a' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
),
|
||||
'c687e867' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
|
|
|
@ -11,7 +11,24 @@ JX.behavior('aphront-form-disable-on-submit', function() {
|
|||
|
||||
JX.Stratcom.listen('click', 'tag:button', function(e) {
|
||||
var raw = e.getRawEvent();
|
||||
new_tab = (raw.altKey || raw.ctrlKey || raw.metaKey || raw.shiftKey);
|
||||
// Only set new_tab if raw.detail is set. When Ctrl+Return is used on an
|
||||
// input element, the event is bubbled through like so:
|
||||
// <input> -> <button> -> <form>
|
||||
//
|
||||
// When the event hits the button element, we receive a click event without
|
||||
// any of the *Key properties set to true, even if the key is held down. We
|
||||
// can handle this by ignoring the fake click event, which is detectable
|
||||
// through `raw.detail === 0`. `raw.detail` stolen from CSS Tricks:
|
||||
// https://css-tricks.com/when-a-click-is-not-just-a-click/
|
||||
if (raw.detail !== 0) {
|
||||
new_tab = (raw.altKey || raw.ctrlKey || raw.metaKey || raw.shiftKey);
|
||||
}
|
||||
});
|
||||
|
||||
JX.Stratcom.listen('keydown', 'tag:input', function(e) {
|
||||
var raw = e.getRawEvent();
|
||||
new_tab = e.getSpecialKey() === 'return' &&
|
||||
(raw.altKey || raw.ctrlKey || raw.metaKey || raw.shiftKey);
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue