diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js index d6d8993d3a..bdb437e8d1 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js @@ -510,11 +510,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; } @@ -525,11 +528,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; } diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html index 6b102ba68e..a5fd521ffe 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.html @@ -368,6 +368,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); @@ -381,6 +385,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);