When adding reviewers allow 'esc' to be an ESCAPE HATCH HAYO
Change-Id: Ie9ff95c5614d5d4ff27dfa06aa94afe182af3601
diff --git a/polygerrit-ui/app/elements/gr-reviewer-list.html b/polygerrit-ui/app/elements/gr-reviewer-list.html
index 7fbb703..a799415 100644
--- a/polygerrit-ui/app/elements/gr-reviewer-list.html
+++ b/polygerrit-ui/app/elements/gr-reviewer-list.html
@@ -103,13 +103,13 @@
selected$="[[_computeSelected(index, _selectedIndex)]]">
<span>[[account.name]]</span>
<span hidden$="[[!account.email]]">
- (<span>[[account.email]]</span>)
+ ([[account.email]])
</span>
</div>
</template>
</div>
</div>
- <a href="#" class="addReviewer" on-tap="_handleAddTap"
+ <a href="#" id="addReviewer" class="addReviewer" on-tap="_handleAddTap"
hidden$="[[_showInput]]">Add reviewer</a>
</div>
</template>
@@ -304,10 +304,7 @@
_handleCancelTap: function(e) {
e.preventDefault();
- this._showInput = false;
- this._selectedIndex = 0;
- this._inputVal = '';
- this._autocompleteData = [];
+ this._cancel();
},
_handleMouseEnterItem: function(e) {
@@ -369,7 +366,14 @@
},
_handleKey: function(e) {
- if (this._hideAutocomplete) { return; }
+ if (this._hideAutocomplete) {
+ if (e.detail.combo == 'esc') {
+ e.preventDefault();
+ this._cancel();
+ }
+ return;
+ }
+
e.preventDefault();
switch (e.detail.combo) {
@@ -389,6 +393,14 @@
}
},
+ _cancel: function() {
+ this._showInput = false;
+ this._selectedIndex = 0;
+ this._inputVal = '';
+ this._autocompleteData = [];
+ this.$.addReviewer.focus();
+ },
+
_sendAddRequest: function() {
this._clearInputRequestHandle();
diff --git a/polygerrit-ui/app/test/gr-reviewer-list-test.html b/polygerrit-ui/app/test/gr-reviewer-list-test.html
index f892ed4..408796d 100644
--- a/polygerrit-ui/app/test/gr-reviewer-list-test.html
+++ b/polygerrit-ui/app/test/gr-reviewer-list-test.html
@@ -123,6 +123,11 @@
assert.isFalse(
element.$$('.autocompleteContainer').hasAttribute('hidden'));
assert.equal(getActiveElement().id, 'input');
+ MockInteractions.pressAndReleaseKeyOn(element, 27); // 'esc'
+ assert.isFalse(element.$$('.addReviewer').hasAttribute('hidden'));
+ assert.isTrue(
+ element.$$('.autocompleteContainer').hasAttribute('hidden'));
+ assert.equal(getActiveElement().id, 'addReviewer');
});
test('only show remove for removable reviewers', function() {