@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+26 -9
+8 -8
resources/celerity/map.php
··· 10 10 'conpherence.pkg.css' => '2f25eb4f', 11 11 'conpherence.pkg.js' => '020aebcf', 12 12 'core.pkg.css' => 'ac619266', 13 - 'core.pkg.js' => '2eeda9e0', 13 + 'core.pkg.js' => '8c86adab', 14 14 'dark-console.pkg.js' => '187792c2', 15 15 'differential.pkg.css' => '94bb10ca', 16 16 'differential.pkg.js' => '46fcb3af', ··· 476 476 'rsrc/js/core/behavior-device.js' => 'ac2b1e01', 477 477 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6bc7ccf7', 478 478 'rsrc/js/core/behavior-fancy-datepicker.js' => 'b545d0a0', 479 - 'rsrc/js/core/behavior-form.js' => '55d7b788', 479 + 'rsrc/js/core/behavior-form.js' => 'c60fb44a', 480 480 'rsrc/js/core/behavior-gesture.js' => 'b58d1a2a', 481 481 'rsrc/js/core/behavior-global-drag-and-drop.js' => '1cab0e9a', 482 482 'rsrc/js/core/behavior-high-security-warning.js' => 'dae2d55b', ··· 591 591 'javelin-behavior-aphlict-status' => 'c3703a16', 592 592 'javelin-behavior-aphront-basic-tokenizer' => '3b4899b0', 593 593 'javelin-behavior-aphront-drag-and-drop-textarea' => '6bc7ccf7', 594 - 'javelin-behavior-aphront-form-disable-on-submit' => '55d7b788', 594 + 'javelin-behavior-aphront-form-disable-on-submit' => 'c60fb44a', 595 595 'javelin-behavior-aphront-more' => '506aa3f4', 596 596 'javelin-behavior-audio-source' => '3dc5ad43', 597 597 'javelin-behavior-audit-preview' => 'b7b73831', ··· 1432 1432 'javelin-install', 1433 1433 'javelin-dom', 1434 1434 ), 1435 - '55d7b788' => array( 1436 - 'javelin-behavior', 1437 - 'javelin-stratcom', 1438 - 'javelin-dom', 1439 - ), 1440 1435 '5793d835' => array( 1441 1436 'javelin-install', 1442 1437 'javelin-util', ··· 2030 2025 'phui-workcard-view-css', 2031 2026 ), 2032 2027 'c538cbfc' => array( 2028 + 'javelin-behavior', 2029 + 'javelin-stratcom', 2030 + 'javelin-dom', 2031 + ), 2032 + 'c60fb44a' => array( 2033 2033 'javelin-behavior', 2034 2034 'javelin-stratcom', 2035 2035 'javelin-dom',
+18 -1
webroot/rsrc/js/core/behavior-form.js
··· 11 11 12 12 JX.Stratcom.listen('click', 'tag:button', function(e) { 13 13 var raw = e.getRawEvent(); 14 - new_tab = (raw.altKey || raw.ctrlKey || raw.metaKey || raw.shiftKey); 14 + // Only set new_tab if raw.detail is set. When Ctrl+Return is used on an 15 + // input element, the event is bubbled through like so: 16 + // <input> -> <button> -> <form> 17 + // 18 + // When the event hits the button element, we receive a click event without 19 + // any of the *Key properties set to true, even if the key is held down. We 20 + // can handle this by ignoring the fake click event, which is detectable 21 + // through `raw.detail === 0`. `raw.detail` stolen from CSS Tricks: 22 + // https://css-tricks.com/when-a-click-is-not-just-a-click/ 23 + if (raw.detail !== 0) { 24 + new_tab = (raw.altKey || raw.ctrlKey || raw.metaKey || raw.shiftKey); 25 + } 26 + }); 27 + 28 + JX.Stratcom.listen('keydown', 'tag:input', function(e) { 29 + var raw = e.getRawEvent(); 30 + new_tab = e.getSpecialKey() === 'return' && 31 + (raw.altKey || raw.ctrlKey || raw.metaKey || raw.shiftKey); 15 32 }); 16 33 17 34