1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Hide tooltips on any keypress

Summary:
Fixes T4586, where a keystroke like "return" to submit a form could remove DOM nodes rendering a tooltip, leaving the user with a permanent phantom tooltip.

(@spicyj, if you come up with anything better than this feel free to send a followup, but I //think// this is a reasonable fix.)

A nice side effect of this is that it hides any tooltips obscuring a text input when you start typing.

Test Plan: Hovered over a tooltip, pressed a key, tip vanished.

Reviewers: spicyj, btrahan

Reviewed By: btrahan

Subscribers: aran, spicyj, epriestley

Maniphest Tasks: T4586

Differential Revision: https://secure.phabricator.com/D8497
This commit is contained in:
epriestley 2014-03-12 11:29:48 -07:00
parent 27485bc644
commit 82aeb59ecf
2 changed files with 25 additions and 21 deletions

View file

@ -8,7 +8,7 @@ return array(
'names' => 'names' =>
array( array(
'core.pkg.css' => 'c650ab0d', 'core.pkg.css' => 'c650ab0d',
'core.pkg.js' => 'b7bdab05', 'core.pkg.js' => '264721e1',
'darkconsole.pkg.js' => 'ca8671ce', 'darkconsole.pkg.js' => 'ca8671ce',
'differential.pkg.css' => 'd1b3a605', 'differential.pkg.css' => 'd1b3a605',
'differential.pkg.js' => '11a5b750', 'differential.pkg.js' => '11a5b750',
@ -474,7 +474,7 @@ return array(
'rsrc/js/core/behavior-select-on-click.js' => '0e34ca02', 'rsrc/js/core/behavior-select-on-click.js' => '0e34ca02',
'rsrc/js/core/behavior-toggle-class.js' => 'a82a7769', 'rsrc/js/core/behavior-toggle-class.js' => 'a82a7769',
'rsrc/js/core/behavior-tokenizer.js' => 'b3a4b884', 'rsrc/js/core/behavior-tokenizer.js' => 'b3a4b884',
'rsrc/js/core/behavior-tooltip.js' => 'e5dd1c6d', 'rsrc/js/core/behavior-tooltip.js' => '48db4145',
'rsrc/js/core/behavior-watch-anchor.js' => '06e05112', 'rsrc/js/core/behavior-watch-anchor.js' => '06e05112',
'rsrc/js/core/behavior-workflow.js' => '82947dda', 'rsrc/js/core/behavior-workflow.js' => '82947dda',
'rsrc/js/core/phtize.js' => 'd254d646', 'rsrc/js/core/phtize.js' => 'd254d646',
@ -602,7 +602,7 @@ return array(
'javelin-behavior-phabricator-reveal-content' => '8f24abfc', 'javelin-behavior-phabricator-reveal-content' => '8f24abfc',
'javelin-behavior-phabricator-search-typeahead' => 'f6b56f7a', 'javelin-behavior-phabricator-search-typeahead' => 'f6b56f7a',
'javelin-behavior-phabricator-show-all-transactions' => '7c273581', 'javelin-behavior-phabricator-show-all-transactions' => '7c273581',
'javelin-behavior-phabricator-tooltips' => 'e5dd1c6d', 'javelin-behavior-phabricator-tooltips' => '48db4145',
'javelin-behavior-phabricator-transaction-comment-form' => '9084a36f', 'javelin-behavior-phabricator-transaction-comment-form' => '9084a36f',
'javelin-behavior-phabricator-transaction-list' => '3c918aa8', 'javelin-behavior-phabricator-transaction-list' => '3c918aa8',
'javelin-behavior-phabricator-watch-anchor' => '06e05112', 'javelin-behavior-phabricator-watch-anchor' => '06e05112',
@ -1116,6 +1116,13 @@ return array(
4 => 'javelin-util', 4 => 'javelin-util',
5 => 'phabricator-prefab', 5 => 'phabricator-prefab',
), ),
'48db4145' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-behavior-device',
2 => 'javelin-stratcom',
3 => 'phabricator-tooltip',
),
'493665ee' => '493665ee' =>
array( array(
0 => 'javelin-install', 0 => 'javelin-install',
@ -1229,6 +1236,11 @@ return array(
2 => 'javelin-util', 2 => 'javelin-util',
3 => 'phabricator-shaped-request', 3 => 'phabricator-shaped-request',
), ),
'7319e029' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
),
'62e18640' => '62e18640' =>
array( array(
0 => 'javelin-install', 0 => 'javelin-install',
@ -1264,11 +1276,6 @@ return array(
1 => 'javelin-stratcom', 1 => 'javelin-stratcom',
2 => 'javelin-dom', 2 => 'javelin-dom',
), ),
'7319e029' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
),
'75903ee1' => '75903ee1' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
@ -1836,13 +1843,6 @@ return array(
2 => 'javelin-view-visitor', 2 => 'javelin-view-visitor',
3 => 'javelin-util', 3 => 'javelin-util',
), ),
'e5dd1c6d' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-behavior-device',
2 => 'javelin-stratcom',
3 => 'phabricator-tooltip',
),
'e7c21fb3' => 'e7c21fb3' =>
array( array(
0 => 'javelin-dom', 0 => 'javelin-dom',

View file

@ -31,14 +31,18 @@ JX.behavior('phabricator-tooltips', function(config) {
data.tip); data.tip);
}); });
function wipe(e) {
JX.Tooltip.hide();
}
// Hide tips when any key is pressed. This prevents tips from ending up locked
// on screen if you make a keypress which removes the underlying node (for
// example, submitting an inline comment in Differential). See T4586.
JX.Stratcom.listen('keydown', null, wipe);
// When we leave the page, hide any visible tooltips. If we don't do this, // When we leave the page, hide any visible tooltips. If we don't do this,
// clicking a link with a tooltip and then hitting "back" will give you a // clicking a link with a tooltip and then hitting "back" will give you a
// phantom tooltip. // phantom tooltip.
JX.Stratcom.listen( JX.Stratcom.listen('unload', null, wipe);
'unload',
null,
function(e) {
JX.Tooltip.hide();
});
}); });