Merge "Add keyboard shortcuts for expanding and collapsing all messages"

This commit is contained in:
Wyatt Allen
2017-01-09 22:27:54 +00:00
committed by Gerrit Code Review
4 changed files with 66 additions and 4 deletions

View File

@@ -129,6 +129,8 @@
'd': '_handleDKey',
's': '_handleSKey',
'u': '_handleUKey',
'x': '_handleXKey',
'z': '_handleZKey',
},
attached: function() {
@@ -652,6 +654,22 @@
this._determinePageBack();
},
_handleXKey: function(e) {
if (this.shouldSuppressKeyboardShortcut(e) ||
this.modifierPressed(e)) { return; }
e.preventDefault();
this.$.messageList.handleExpandCollapse(true);
},
_handleZKey: function(e) {
if (this.shouldSuppressKeyboardShortcut(e) ||
this.modifierPressed(e)) { return; }
e.preventDefault();
this.$.messageList.handleExpandCollapse(false);
},
_determinePageBack: function() {
// Default backPage to '/' if user came to change view page
// via an email link, etc.

View File

@@ -85,6 +85,20 @@ limitations under the License.
assert.isFalse(overlayEl.opened);
});
test('X should expand all messages', function() {
var handleExpand =
sandbox.stub(element.$.messageList, 'handleExpandCollapse');
MockInteractions.pressAndReleaseKeyOn(element, 88, null, 'x');
assert(handleExpand.calledWith(true));
});
test('Z should collapse all messages', function() {
var handleExpand =
sandbox.stub(element.$.messageList, 'handleExpandCollapse');
MockInteractions.pressAndReleaseKeyOn(element, 90, null, 'z');
assert(handleExpand.calledWith(false));
});
test('shift + R should fetch and navigate to the latest patch set',
function(done) {
element._changeNum = '42';