From 22551d106d35f2e42716168e92784dc8c08ddf6d Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 12 Nov 2014 12:26:22 -0800 Subject: [PATCH] diffusion / differential - better handle case where no comment selected Summary: Right now, if no comment is selected the JS executes and throws an exception. Instead, if nothing is selected just do nothing. Fixes T6107. Test Plan: opened up a commit in diffusion with an inline comment. pressed 'r' and saw no exceptions and nothing happen. pressed 'n' to select the next inline comment and then 'r' and it worked. opened up a commit in diffusion without any inline comments. pressed 'r' and saw no exceptions and nothing happen. opened up a diff in differential with an inline comment. pressed 'r' and saw no exceptons and nothing happened. pressed 'n' to select the next inline comment and then 'r' and it worked. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6107 Differential Revision: https://secure.phabricator.com/D10843 --- resources/celerity/map.php | 18 +++++++++--------- .../differential/behavior-keyboard-nav.js | 4 ++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 798e6b1c5b..9ac7d22d63 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -11,7 +11,7 @@ return array( 'core.pkg.js' => 'cbdbd552', 'darkconsole.pkg.js' => 'df001cab', 'differential.pkg.css' => '8af45893', - 'differential.pkg.js' => '85cb2027', + 'differential.pkg.js' => '42c10e78', 'diffusion.pkg.css' => '591664fa', 'diffusion.pkg.js' => 'bfc0737b', 'maniphest.pkg.css' => 'e34dfbec', @@ -369,7 +369,7 @@ return array( 'rsrc/js/application/differential/behavior-diff-radios.js' => 'e1ff79b1', 'rsrc/js/application/differential/behavior-dropdown-menus.js' => '710f209e', 'rsrc/js/application/differential/behavior-edit-inline-comments.js' => '00861799', - 'rsrc/js/application/differential/behavior-keyboard-nav.js' => '8d199d97', + 'rsrc/js/application/differential/behavior-keyboard-nav.js' => '2c426492', 'rsrc/js/application/differential/behavior-populate.js' => 'bdb3e4d0', 'rsrc/js/application/differential/behavior-show-all-comments.js' => '7c273581', 'rsrc/js/application/differential/behavior-show-field-details.js' => 'bba9eedf', @@ -572,7 +572,7 @@ return array( 'javelin-behavior-differential-dropdown-menus' => '710f209e', 'javelin-behavior-differential-edit-inline-comments' => '00861799', 'javelin-behavior-differential-feedback-preview' => '6932def3', - 'javelin-behavior-differential-keyboard-navigation' => '8d199d97', + 'javelin-behavior-differential-keyboard-navigation' => '2c426492', 'javelin-behavior-differential-populate' => 'bdb3e4d0', 'javelin-behavior-differential-show-field-details' => 'bba9eedf', 'javelin-behavior-differential-show-more' => 'dd7e8ef5', @@ -1009,6 +1009,12 @@ return array( 'javelin-stratcom', 'javelin-dom', ), + '2c426492' => array( + 'javelin-behavior', + 'javelin-dom', + 'javelin-stratcom', + 'phabricator-keyboard-shortcut', + ), '2fa810fc' => array( 'javelin-behavior', 'javelin-dom', @@ -1416,12 +1422,6 @@ return array( 'javelin-uri', 'phabricator-file-upload', ), - '8d199d97' => array( - 'javelin-behavior', - 'javelin-dom', - 'javelin-stratcom', - 'phabricator-keyboard-shortcut', - ), '8ef9ab58' => array( 'javelin-behavior', 'javelin-dom', diff --git a/webroot/rsrc/js/application/differential/behavior-keyboard-nav.js b/webroot/rsrc/js/application/differential/behavior-keyboard-nav.js index 3acca2b6a7..da97d908b2 100644 --- a/webroot/rsrc/js/application/differential/behavior-keyboard-nav.js +++ b/webroot/rsrc/js/application/differential/behavior-keyboard-nav.js @@ -242,6 +242,10 @@ JX.behavior('differential-keyboard-navigation', function(config) { function inline_op(node, op) { + // nothing selected + if (!node) { + return; + } if (!JX.DOM.scry(node, 'a', 'differential-inline-' + op)) { // No link for this operation, e.g. editing a comment you can't edit. return;