From 1f965adfc447e4567b5ff97f73a01df7e2300dab Mon Sep 17 00:00:00 2001 From: Becky Siegel Date: Tue, 28 Feb 2017 11:17:41 -0800 Subject: [PATCH] In "expand files inline" mode open in new tab with meta/control click Previously, whenever a file was clicked when the expand inline files preference was set, the file was expanded. This was true even with the meta or control keycode modifier. This change respects the default behavior (opening in a new tab) when clicked with the meta modifier key. Bug: issue 5663 Change-Id: I8ede3b2efbffff739353a38d9e1f952c74188efd --- .../change/gr-file-list/gr-file-list.html | 2 +- .../change/gr-file-list/gr-file-list.js | 3 +- .../gr-file-list/gr-file-list_test.html | 29 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html index a428785055..0a02e0850d 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html @@ -249,7 +249,7 @@ limitations under the License. + on-tap="_handleFileTap">
[[_computeFileDisplayName(file.__path)]] 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 641cf0c2d0..45f750c45b 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 @@ -396,9 +396,10 @@ }); }, - _handleFileClick: function(e) { + _handleFileTap: function(e) { // If the user prefers to expand inline diffs rather than opening the diff // view, intercept the click event. + if (e.metaKey || e.ctrlKey) { return; } if (this._userPrefs && this._userPrefs.expand_inline_diffs) { e.preventDefault(); this._handleHiddenChange(e); 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 4ff3421424..c37acf6db5 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 @@ -768,6 +768,35 @@ limitations under the License. element.push('_expandedFilePaths', path); }); + suite('_handleFileTap', function() { + function testForModifier(modifier) { + var e = {preventDefault: function() {}}; + e[modifier] = true; + + var hiddenChangeStub = sandbox.stub(element, '_handleHiddenChange'); + element._userPrefs = { expand_inline_diffs: true }; + + element._handleFileTap(e); + assert.isFalse(hiddenChangeStub.called); + + e[modifier] = false; + element._handleFileTap(e); + assert.equal(hiddenChangeStub.callCount, 1); + + element._userPrefs = { expand_inline_diffs: false }; + element._handleFileTap(e); + assert.equal(hiddenChangeStub.callCount, 1); + } + + test('_handleFileTap meta', function() { + testForModifier('metaKey'); + }); + + test('_handleFileTap ctrl', function() { + testForModifier('ctrlKey'); + }); + }); + test('_renderInOrder', function(done) { var callCount = 0; var diffs = [{