Don't curse over files with up/down keys
Previously, if up/down keys were pressed, and the cursor was to move over files rather than the diff rows, the file list cursor would move up or down. Because this interfered with the browser's native scrolling with up/down keys, that behavior has been removed. The j/k keys still work as they did before. Bug: Issue 7815 Change-Id: Iaf031f845293a3605a88a9e656eb000b0e4e196f
This commit is contained in:
@@ -493,11 +493,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
if (this._showInlineDiffs) {
|
||||
e.preventDefault();
|
||||
this.$.diffCursor.moveDown();
|
||||
this._displayLine = true;
|
||||
} else {
|
||||
// Down key
|
||||
if (this.getKeyboardEvent(e).keyCode === 40) { return; }
|
||||
e.preventDefault();
|
||||
this.$.fileCursor.next();
|
||||
this.selectedIndex = this.$.fileCursor.index;
|
||||
}
|
||||
@@ -508,11 +511,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
if (this._showInlineDiffs) {
|
||||
e.preventDefault();
|
||||
this.$.diffCursor.moveUp();
|
||||
this._displayLine = true;
|
||||
} else {
|
||||
// Up key
|
||||
if (this.getKeyboardEvent(e).keyCode === 38) { return; }
|
||||
e.preventDefault();
|
||||
this.$.fileCursor.previous();
|
||||
this.selectedIndex = this.$.fileCursor.index;
|
||||
}
|
||||
|
||||
@@ -520,6 +520,10 @@ limitations under the License.
|
||||
// j with a modifier should not move the cursor.
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74, 'shift', 'j');
|
||||
assert.equal(element.$.fileCursor.index, 0);
|
||||
// down should not move the cursor.
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 40, null, 'down');
|
||||
assert.equal(element.$.fileCursor.index, 0);
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74, null, 'j');
|
||||
assert.equal(element.$.fileCursor.index, 1);
|
||||
assert.equal(element.selectedIndex, 1);
|
||||
@@ -533,6 +537,10 @@ limitations under the License.
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75, 'shift', 'k');
|
||||
assert.equal(element.$.fileCursor.index, 2);
|
||||
|
||||
// up should not move the cursor.
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 38, null, 'down');
|
||||
assert.equal(element.$.fileCursor.index, 2);
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
|
||||
assert.equal(element.$.fileCursor.index, 1);
|
||||
assert.equal(element.selectedIndex, 1);
|
||||
|
||||
Reference in New Issue
Block a user