Merge "Add ctrl+s as keyboard shortcut to save comment draft"

This commit is contained in:
Andrew Bonventre
2016-08-27 03:11:48 +00:00
committed by Gerrit Code Review
2 changed files with 21 additions and 2 deletions

View File

@@ -198,8 +198,15 @@
},
_handleTextareaKeydown: function(e) {
if (e.keyCode == 27) { // 'esc'
switch (e.keyCode) {
case 27: // 'esc'
this._handleCancel(e);
break;
case 83: // 's'
if (e.ctrlKey) {
this._handleSave(e);
}
break;
}
},

View File

@@ -211,6 +211,18 @@ limitations under the License.
MockInteractions.pressAndReleaseKeyOn(element.$.editTextarea, 27); // esc
});
test('ctrl+s saves comment', function(done) {
var stub = sinon.stub(element, 'save', function() {
assert.isTrue(stub.called);
stub.restore();
done();
});
element._messageText = 'is that the horse from horsing around??';
MockInteractions.pressAndReleaseKeyOn(
element.$.editTextarea.textarea,
83, 'ctrl'); // 'ctrl + s'
});
test('draft saving/editing', function(done) {
var fireStub = sinon.stub(element, 'fire');