From 0ea95d41a67f19bf245dbc8b19d266fe2aeae3ef Mon Sep 17 00:00:00 2001 From: BlankEclair Date: Mon, 25 Nov 2024 21:06:45 +1100 Subject: [PATCH] Fix submitting forms in a new tab using Ctrl+Return Summary: This commit adds a keydown listener to 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 --- resources/celerity/map.php | 16 ++++++++-------- webroot/rsrc/js/core/behavior-form.js | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 661e474efb..18a0c7c6f9 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -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', diff --git a/webroot/rsrc/js/core/behavior-form.js b/webroot/rsrc/js/core/behavior-form.js index 01f88e2b09..3df9574433 100644 --- a/webroot/rsrc/js/core/behavior-form.js +++ b/webroot/rsrc/js/core/behavior-form.js @@ -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: + // ->