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
This commit is contained in:
Becky Siegel
2017-02-28 11:17:41 -08:00
parent 08f265c97f
commit 1f965adfc4
3 changed files with 32 additions and 2 deletions

View File

@@ -249,7 +249,7 @@ limitations under the License.
</div>
<a class$="[[_computePathClass(file.__path, _expandedFilePaths.*)]]"
href$="[[_computeDiffURL(changeNum, patchRange, file.__path)]]"
on-click="_handleFileClick">
on-tap="_handleFileTap">
<div title$="[[_computeFileDisplayName(file.__path)]]"
class="fullFileName">
[[_computeFileDisplayName(file.__path)]]

View File

@@ -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);

View File

@@ -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 = [{