Short circuit file-list key handler when links are focused
Bug: Issue 5754 Change-Id: I65087be7aab102bf33915f0a438308cd84f6e97d
This commit is contained in:
@@ -492,6 +492,10 @@
|
|||||||
if (this.shouldSuppressKeyboardShortcut(e) ||
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
||||||
this.modifierPressed(e)) { return; }
|
this.modifierPressed(e)) { return; }
|
||||||
|
|
||||||
|
// Use native handling if an anchor is selected. @see Issue 5754
|
||||||
|
if (e.detail && e.detail.keyboardEvent && e.detail.keyboardEvent.target &&
|
||||||
|
e.detail.keyboardEvent.target.tagName === 'A') { return; }
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this._showInlineDiffs) {
|
if (this._showInlineDiffs) {
|
||||||
this._openCursorFile();
|
this._openCursorFile();
|
||||||
|
|||||||
@@ -357,6 +357,44 @@ limitations under the License.
|
|||||||
element.diffs[index].path);
|
element.diffs[index].path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('_handleEnterKey navigates', function() {
|
||||||
|
sandbox.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
|
||||||
|
sandbox.stub(element, 'modifierPressed').returns(false);
|
||||||
|
var expandStub = sandbox.stub(element, '_openCursorFile');
|
||||||
|
var navStub = sandbox.stub(element, '_openSelectedFile');
|
||||||
|
var e = new CustomEvent('fake-keyboard-event');
|
||||||
|
sinon.stub(e, 'preventDefault');
|
||||||
|
element._showInlineDiffs = false;
|
||||||
|
element._handleEnterKey(e);
|
||||||
|
assert.isTrue(e.preventDefault.called);
|
||||||
|
assert.isTrue(navStub.called);
|
||||||
|
assert.isFalse(expandStub.called);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_handleEnterKey expands', function() {
|
||||||
|
sandbox.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
|
||||||
|
sandbox.stub(element, 'modifierPressed').returns(false);
|
||||||
|
var expandStub = sandbox.stub(element, '_openCursorFile');
|
||||||
|
var navStub = sandbox.stub(element, '_openSelectedFile');
|
||||||
|
var e = new CustomEvent('fake-keyboard-event');
|
||||||
|
sinon.stub(e, 'preventDefault');
|
||||||
|
element._showInlineDiffs = true;
|
||||||
|
element._handleEnterKey(e);
|
||||||
|
assert.isTrue(e.preventDefault.called);
|
||||||
|
assert.isFalse(navStub.called);
|
||||||
|
assert.isTrue(expandStub.called);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_handleEnterKey noop when anchor focused', function() {
|
||||||
|
sandbox.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
|
||||||
|
sandbox.stub(element, 'modifierPressed').returns(false);
|
||||||
|
var e = new CustomEvent('fake-keyboard-event',
|
||||||
|
{detail: {keyboardEvent: {target: document.createElement('a')}}});
|
||||||
|
sinon.stub(e, 'preventDefault');
|
||||||
|
element._handleEnterKey(e);
|
||||||
|
assert.isFalse(e.preventDefault.called);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('comment filtering', function() {
|
test('comment filtering', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user