Remove everywhere on-tap

Recommended by polymer team to remove legacy on tap for on click.
On click has better performance and is well supported by browsers.

Change-Id: I30a03ae9c7f721d561b11784d07fb186a9fa0407
This commit is contained in:
Milutin Kristofic
2019-10-28 15:40:44 +01:00
parent b0ae5468d1
commit 5b1b46f56a
29 changed files with 72 additions and 72 deletions

View File

@@ -89,7 +89,7 @@
this._tooltip = tooltip; this._tooltip = tooltip;
this.listen(window, 'scroll', '_handleWindowScroll'); this.listen(window, 'scroll', '_handleWindowScroll');
this.listen(this, 'mouseleave', '_handleHideTooltip'); this.listen(this, 'mouseleave', '_handleHideTooltip');
this.listen(this, 'tap', '_handleHideTooltip'); this.listen(this, 'click', '_handleHideTooltip');
}, },
_handleHideTooltip(e) { _handleHideTooltip(e) {
@@ -101,7 +101,7 @@
this.unlisten(window, 'scroll', '_handleWindowScroll'); this.unlisten(window, 'scroll', '_handleWindowScroll');
this.unlisten(this, 'mouseleave', '_handleHideTooltip'); this.unlisten(this, 'mouseleave', '_handleHideTooltip');
this.unlisten(this, 'tap', '_handleHideTooltip'); this.unlisten(this, 'click', '_handleHideTooltip');
this.setAttribute('title', this._titleText); this.setAttribute('title', this._titleText);
if (this._tooltip && this._tooltip.parentNode) { if (this._tooltip && this._tooltip.parentNode) {
this._tooltip.parentNode.removeChild(this._tooltip); this._tooltip.parentNode.removeChild(this._tooltip);

View File

@@ -127,7 +127,7 @@ limitations under the License.
<section class$="spacer [[_computeShowOptional(_optionalLabels.*)]]"></section> <section class$="spacer [[_computeShowOptional(_optionalLabels.*)]]"></section>
<section <section
show-bottom-border$="[[_showOptionalLabels]]" show-bottom-border$="[[_showOptionalLabels]]"
on-tap="_handleShowHide" on-click="_handleShowHide"
class$="showHide [[_computeShowOptional(_optionalLabels.*)]]"> class$="showHide [[_computeShowOptional(_optionalLabels.*)]]">
<div class="title">Other labels</div> <div class="title">Other labels</div>
<div class="value"> <div class="value">

View File

@@ -62,7 +62,7 @@ limitations under the License.
<input id="rebaseOnParentInput" <input id="rebaseOnParentInput"
name="rebaseOptions" name="rebaseOptions"
type="radio" type="radio"
on-tap="_handleRebaseOnParent"> on-click="_handleRebaseOnParent">
<label id="rebaseOnParentLabel" for="rebaseOnParentInput"> <label id="rebaseOnParentLabel" for="rebaseOnParentInput">
Rebase on parent change Rebase on parent change
</label> </label>
@@ -77,7 +77,7 @@ limitations under the License.
name="rebaseOptions" name="rebaseOptions"
type="radio" type="radio"
disabled$="[[!_displayTipOption(rebaseOnCurrent, hasParent)]]" disabled$="[[!_displayTipOption(rebaseOnCurrent, hasParent)]]"
on-tap="_handleRebaseOnTip"> on-click="_handleRebaseOnTip">
<label id="rebaseOnTipLabel" for="rebaseOnTipInput"> <label id="rebaseOnTipLabel" for="rebaseOnTipInput">
Rebase on top of the [[branch]] Rebase on top of the [[branch]]
branch<span hidden$="[[!hasParent]]"> branch<span hidden$="[[!hasParent]]">
@@ -93,7 +93,7 @@ limitations under the License.
<input id="rebaseOnOtherInput" <input id="rebaseOnOtherInput"
name="rebaseOptions" name="rebaseOptions"
type="radio" type="radio"
on-tap="_handleRebaseOnOther"> on-click="_handleRebaseOnOther">
<label id="rebaseOnOtherLabel" for="rebaseOnOtherInput"> <label id="rebaseOnOtherLabel" for="rebaseOnOtherInput">
Rebase on a specific change, ref, or commit <span hidden$="[[!hasParent]]"> Rebase on a specific change, ref, or commit <span hidden$="[[!hasParent]]">
(breaks relation chain) (breaks relation chain)
@@ -106,7 +106,7 @@ limitations under the License.
query="[[_query]]" query="[[_query]]"
no-debounce no-debounce
text="{{_text}}" text="{{_text}}"
on-tap="_handleEnterChangeNumberTap" on-click="_handleEnterChangeNumberClick"
allow-non-suggested-values allow-non-suggested-values
placeholder="Change number, ref, or commit hash"> placeholder="Change number, ref, or commit hash">
</gr-autocomplete> </gr-autocomplete>

View File

@@ -136,7 +136,7 @@
this.$.parentInput.focus(); this.$.parentInput.focus();
}, },
_handleEnterChangeNumberTap() { _handleEnterChangeNumberClick() {
this.$.rebaseOnOtherInput.checked = true; this.$.rebaseOnOtherInput.checked = true;
}, },

View File

@@ -280,7 +280,7 @@ limitations under the License.
</style> </style>
<div <div
id="container" id="container"
on-tap="_handleFileListTap"> on-click="_handleFileListClick">
<div class="header-row row"> <div class="header-row row">
<div class="status"></div> <div class="status"></div>
<div class="path">File</div> <div class="path">File</div>

View File

@@ -561,7 +561,7 @@
* Handle all events from the file list dom-repeat so event handleers don't * Handle all events from the file list dom-repeat so event handleers don't
* have to get registered for potentially very long lists. * have to get registered for potentially very long lists.
*/ */
_handleFileListTap(e) { _handleFileListClick(e) {
// Traverse upwards to find the row element if the target is not the row. // Traverse upwards to find the row element if the target is not the row.
let row = e.target; let row = e.target;
while (!row.classList.contains('row') && row.parentElement) { while (!row.classList.contains('row') && row.parentElement) {

View File

@@ -817,18 +817,18 @@ limitations under the License.
assert.isTrue(commitReviewLabel.classList.contains('isReviewed')); assert.isTrue(commitReviewLabel.classList.contains('isReviewed'));
assert.equal(markReviewLabel.textContent, 'MARK UNREVIEWED'); assert.equal(markReviewLabel.textContent, 'MARK UNREVIEWED');
const tapSpy = sandbox.spy(element, '_handleFileListTap'); const clickSpy = sandbox.spy(element, '_handleFileListClick');
MockInteractions.tap(markReviewLabel); MockInteractions.tap(markReviewLabel);
assert.isTrue(saveStub.lastCall.calledWithExactly('/COMMIT_MSG', false)); assert.isTrue(saveStub.lastCall.calledWithExactly('/COMMIT_MSG', false));
assert.isFalse(commitReviewLabel.classList.contains('isReviewed')); assert.isFalse(commitReviewLabel.classList.contains('isReviewed'));
assert.equal(markReviewLabel.textContent, 'MARK REVIEWED'); assert.equal(markReviewLabel.textContent, 'MARK REVIEWED');
assert.isTrue(tapSpy.lastCall.args[0].defaultPrevented); assert.isTrue(clickSpy.lastCall.args[0].defaultPrevented);
MockInteractions.tap(markReviewLabel); MockInteractions.tap(markReviewLabel);
assert.isTrue(saveStub.lastCall.calledWithExactly('/COMMIT_MSG', true)); assert.isTrue(saveStub.lastCall.calledWithExactly('/COMMIT_MSG', true));
assert.isTrue(commitReviewLabel.classList.contains('isReviewed')); assert.isTrue(commitReviewLabel.classList.contains('isReviewed'));
assert.equal(markReviewLabel.textContent, 'MARK UNREVIEWED'); assert.equal(markReviewLabel.textContent, 'MARK UNREVIEWED');
assert.isTrue(tapSpy.lastCall.args[0].defaultPrevented); assert.isTrue(clickSpy.lastCall.args[0].defaultPrevented);
}); });
test('_computeFileStatusLabel', () => { test('_computeFileStatusLabel', () => {
@@ -836,7 +836,7 @@ limitations under the License.
assert.equal(element._computeFileStatusLabel('M'), 'Modified'); assert.equal(element._computeFileStatusLabel('M'), 'Modified');
}); });
test('_handleFileListTap', () => { test('_handleFileListClick', () => {
element._filesByPath = { element._filesByPath = {
'/COMMIT_MSG': {}, '/COMMIT_MSG': {},
'f1.txt': {}, 'f1.txt': {},
@@ -848,7 +848,7 @@ limitations under the License.
patchNum: '2', patchNum: '2',
}; };
const tapSpy = sandbox.spy(element, '_handleFileListTap'); const clickSpy = sandbox.spy(element, '_handleFileListClick');
const reviewStub = sandbox.stub(element, '_reviewFile'); const reviewStub = sandbox.stub(element, '_reviewFile');
const toggleExpandSpy = sandbox.spy(element, '_togglePathExpanded'); const toggleExpandSpy = sandbox.spy(element, '_togglePathExpanded');
@@ -858,26 +858,26 @@ limitations under the License.
// Click on the expand button, resulting in _togglePathExpanded being // Click on the expand button, resulting in _togglePathExpanded being
// called and not resulting in a call to _reviewFile. // called and not resulting in a call to _reviewFile.
row.querySelector('div.show-hide').click(); row.querySelector('div.show-hide').click();
assert.isTrue(tapSpy.calledOnce); assert.isTrue(clickSpy.calledOnce);
assert.isTrue(toggleExpandSpy.calledOnce); assert.isTrue(toggleExpandSpy.calledOnce);
assert.isFalse(reviewStub.called); assert.isFalse(reviewStub.called);
// Click inside the diff. This should result in no additional calls to // Click inside the diff. This should result in no additional calls to
// _togglePathExpanded or _reviewFile. // _togglePathExpanded or _reviewFile.
Polymer.dom(element.root).querySelector('gr-diff-host').click(); Polymer.dom(element.root).querySelector('gr-diff-host').click();
assert.isTrue(tapSpy.calledTwice); assert.isTrue(clickSpy.calledTwice);
assert.isTrue(toggleExpandSpy.calledOnce); assert.isTrue(toggleExpandSpy.calledOnce);
assert.isFalse(reviewStub.called); assert.isFalse(reviewStub.called);
// Click the reviewed checkbox, resulting in a call to _reviewFile, but // Click the reviewed checkbox, resulting in a call to _reviewFile, but
// no additional call to _togglePathExpanded. // no additional call to _togglePathExpanded.
row.querySelector('.markReviewed').click(); row.querySelector('.markReviewed').click();
assert.isTrue(tapSpy.calledThrice); assert.isTrue(clickSpy.calledThrice);
assert.isTrue(toggleExpandSpy.calledOnce); assert.isTrue(toggleExpandSpy.calledOnce);
assert.isTrue(reviewStub.calledOnce); assert.isTrue(reviewStub.calledOnce);
}); });
test('_handleFileListTap editMode', () => { test('_handleFileListClick editMode', () => {
element._filesByPath = { element._filesByPath = {
'/COMMIT_MSG': {}, '/COMMIT_MSG': {},
'f1.txt': {}, 'f1.txt': {},
@@ -890,12 +890,12 @@ limitations under the License.
}; };
element.editMode = true; element.editMode = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
const tapSpy = sandbox.spy(element, '_handleFileListTap'); const clickSpy = sandbox.spy(element, '_handleFileListClick');
const toggleExpandSpy = sandbox.spy(element, '_togglePathExpanded'); const toggleExpandSpy = sandbox.spy(element, '_togglePathExpanded');
// Tap the edit controls. Should be ignored by _handleFileListTap. // Tap the edit controls. Should be ignored by _handleFileListClick.
MockInteractions.tap(element.$$('.editFileControls')); MockInteractions.tap(element.$$('.editFileControls'));
assert.isTrue(tapSpy.calledOnce); assert.isTrue(clickSpy.calledOnce);
assert.isFalse(toggleExpandSpy.called); assert.isFalse(toggleExpandSpy.called);
}); });

View File

@@ -55,11 +55,11 @@ limitations under the License.
<tr> <tr>
<td>Number</td> <td>Number</td>
<td class="checkboxContainer" <td class="checkboxContainer"
on-tap="_handleCheckboxContainerTap"> on-click="_handleCheckboxContainerClick">
<input <input
type="checkbox" type="checkbox"
name="number" name="number"
on-tap="_handleNumberCheckboxTap" on-click="_handleNumberCheckboxClick"
checked$="[[showNumber]]"> checked$="[[showNumber]]">
</td> </td>
</tr> </tr>
@@ -67,11 +67,11 @@ limitations under the License.
<tr> <tr>
<td>[[item]]</td> <td>[[item]]</td>
<td class="checkboxContainer" <td class="checkboxContainer"
on-tap="_handleCheckboxContainerTap"> on-click="_handleCheckboxContainerClick">
<input <input
type="checkbox" type="checkbox"
name="[[item]]" name="[[item]]"
on-tap="_handleTargetTap" on-click="_handleTargetClick"
checked$="[[!isColumnHidden(item, displayedColumns)]]"> checked$="[[!isColumnHidden(item, displayedColumns)]]">
</td> </td>
</tr> </tr>

View File

@@ -49,28 +49,28 @@
}, },
/** /**
* Handle a tap on a checkbox container and relay the tap to the checkbox it * Handle a click on a checkbox container and relay the click to the checkbox it
* contains. * contains.
*/ */
_handleCheckboxContainerTap(e) { _handleCheckboxContainerClick(e) {
const checkbox = Polymer.dom(e.target).querySelector('input'); const checkbox = Polymer.dom(e.target).querySelector('input');
if (!checkbox) { return; } if (!checkbox) { return; }
checkbox.click(); checkbox.click();
}, },
/** /**
* Handle a tap on the number checkbox and update the showNumber property * Handle a click on the number checkbox and update the showNumber property
* accordingly. * accordingly.
*/ */
_handleNumberCheckboxTap(e) { _handleNumberCheckboxClick(e) {
this.showNumber = Polymer.dom(e).rootTarget.checked; this.showNumber = Polymer.dom(e).rootTarget.checked;
}, },
/** /**
* Handle a tap on a displayed column checkboxes (excluding number) and * Handle a click on a displayed column checkboxes (excluding number) and
* update the displayedColumns property accordingly. * update the displayedColumns property accordingly.
*/ */
_handleTargetTap(e) { _handleTargetClick(e) {
this.set('displayedColumns', this._getDisplayedColumns()); this.set('displayedColumns', this._getDisplayedColumns());
}, },
}); });

View File

@@ -119,41 +119,41 @@ limitations under the License.
columns.filter(c => c !== 'Assignee')); columns.filter(c => c !== 'Assignee'));
}); });
test('_handleCheckboxContainerTap relayes taps to checkboxes', () => { test('_handleCheckboxContainerClick relayes taps to checkboxes', () => {
sandbox.stub(element, '_handleNumberCheckboxTap'); sandbox.stub(element, '_handleNumberCheckboxClick');
sandbox.stub(element, '_handleTargetTap'); sandbox.stub(element, '_handleTargetClick');
MockInteractions.tap( MockInteractions.tap(
element.$$('table tr:first-of-type .checkboxContainer')); element.$$('table tr:first-of-type .checkboxContainer'));
assert.isTrue(element._handleNumberCheckboxTap.calledOnce); assert.isTrue(element._handleNumberCheckboxClick.calledOnce);
assert.isFalse(element._handleTargetTap.called); assert.isFalse(element._handleTargetClick.called);
MockInteractions.tap( MockInteractions.tap(
element.$$('table tr:last-of-type .checkboxContainer')); element.$$('table tr:last-of-type .checkboxContainer'));
assert.isTrue(element._handleNumberCheckboxTap.calledOnce); assert.isTrue(element._handleNumberCheckboxClick.calledOnce);
assert.isTrue(element._handleTargetTap.calledOnce); assert.isTrue(element._handleTargetClick.calledOnce);
}); });
test('_handleNumberCheckboxTap', () => { test('_handleNumberCheckboxClick', () => {
sandbox.spy(element, '_handleNumberCheckboxTap'); sandbox.spy(element, '_handleNumberCheckboxClick');
MockInteractions MockInteractions
.tap(element.$$('.checkboxContainer input[name=number]')); .tap(element.$$('.checkboxContainer input[name=number]'));
assert.isTrue(element._handleNumberCheckboxTap.calledOnce); assert.isTrue(element._handleNumberCheckboxClick.calledOnce);
assert.isTrue(element.showNumber); assert.isTrue(element.showNumber);
MockInteractions MockInteractions
.tap(element.$$('.checkboxContainer input[name=number]')); .tap(element.$$('.checkboxContainer input[name=number]'));
assert.isTrue(element._handleNumberCheckboxTap.calledTwice); assert.isTrue(element._handleNumberCheckboxClick.calledTwice);
assert.isFalse(element.showNumber); assert.isFalse(element.showNumber);
}); });
test('_handleTargetTap', () => { test('_handleTargetClick', () => {
sandbox.spy(element, '_handleTargetTap'); sandbox.spy(element, '_handleTargetClick');
assert.include(element.displayedColumns, 'Assignee'); assert.include(element.displayedColumns, 'Assignee');
MockInteractions MockInteractions
.tap(element.$$('.checkboxContainer input[name=Assignee]')); .tap(element.$$('.checkboxContainer input[name=Assignee]'));
assert.isTrue(element._handleTargetTap.calledOnce); assert.isTrue(element._handleTargetClick.calledOnce);
assert.notInclude(element.displayedColumns, 'Assignee'); assert.notInclude(element.displayedColumns, 'Assignee');
}); });
}); });

View File

@@ -77,7 +77,7 @@ limitations under the License.
type="radio" type="radio"
data-name$="[[item.name]]" data-name$="[[item.name]]"
data-url$="[[item.url]]" data-url$="[[item.url]]"
on-tap="_handleShowAgreement" on-click="_handleShowAgreement"
disabled$="[[_disableAggreements(item, _groups, _signedAgreements)]]"> disabled$="[[_disableAggreements(item, _groups, _signedAgreements)]]">
<label id="claNewAgreementsLabel">[[item.name]]</label> <label id="claNewAgreementsLabel">[[item.name]]</label>
</span> </span>

View File

@@ -62,7 +62,7 @@ limitations under the License.
<template is="dom-repeat" items="[[_emails]]"> <template is="dom-repeat" items="[[_emails]]">
<tr> <tr>
<td class="emailColumn">[[item.email]]</td> <td class="emailColumn">[[item.email]]</td>
<td class="preferredControl" on-tap="_handlePreferredControlTap"> <td class="preferredControl" on-click="_handlePreferredControlClick">
<iron-input <iron-input
class="preferredRadio" class="preferredRadio"
type="radio" type="radio"

View File

@@ -73,7 +73,7 @@
this.hasUnsavedChanges = true; this.hasUnsavedChanges = true;
}, },
_handlePreferredControlTap(e) { _handlePreferredControlClick(e) {
if (e.target.classList.contains('preferredControl')) { if (e.target.classList.contains('preferredControl')) {
e.target.firstElementChild.click(); e.target.firstElementChild.click();
} }

View File

@@ -119,7 +119,7 @@ limitations under the License.
<hr> <hr>
<p> <p>
More configuration options for Gerrit may be found in the More configuration options for Gerrit may be found in the
<a on-tap="close" href$="[[settingsUrl]]">settings</a>. <a on-click="close" href$="[[settingsUrl]]">settings</a>.
</p> </p>
</main> </main>
<footer> <footer>

View File

@@ -74,7 +74,7 @@ limitations under the License.
is="dom-repeat" is="dom-repeat"
items="[[_getTypes()]]" items="[[_getTypes()]]"
as="type"> as="type">
<td class="notifControl" on-tap="_handleNotifCellTap"> <td class="notifControl" on-click="_handleNotifCellClick">
<input <input
type="checkbox" type="checkbox"
data-index$="[[projectIndex]]" data-index$="[[projectIndex]]"

View File

@@ -169,7 +169,7 @@
this.hasUnsavedChanges = true; this.hasUnsavedChanges = true;
}, },
_handleNotifCellTap(e) { _handleNotifCellClick(e) {
const checkbox = Polymer.dom(e.target).querySelector('input'); const checkbox = Polymer.dom(e.target).querySelector('input');
if (checkbox) { checkbox.click(); } if (checkbox) { checkbox.click(); }
}, },

View File

@@ -88,7 +88,7 @@ limitations under the License.
aria-label$="[[item.name]]" aria-label$="[[item.name]]"
class="autocompleteOption" class="autocompleteOption"
role="option" role="option"
on-tap="_handleTapItem"> on-click="_handleClickItem">
<span>[[item.text]]</span> <span>[[item.text]]</span>
<span class$="label [[_computeLabelClass(item)]]">[[item.label]]</span> <span class$="label [[_computeLabelClass(item)]]">[[item.label]]</span>
</li> </li>

View File

@@ -135,7 +135,7 @@
this.close(); this.close();
}, },
_handleTapItem(e) { _handleClickItem(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
let selected = e.target; let selected = e.target;
@@ -144,7 +144,7 @@
selected = selected.parentElement; selected = selected.parentElement;
} }
this.fire('item-selected', { this.fire('item-selected', {
trigger: 'tap', trigger: 'click',
selected, selected,
}); });
}, },

View File

@@ -128,7 +128,7 @@ limitations under the License.
MockInteractions.tap(element.$.suggestions.querySelectorAll('li')[1]); MockInteractions.tap(element.$.suggestions.querySelectorAll('li')[1]);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.deepEqual(itemSelectedStub.lastCall.args[0].detail, { assert.deepEqual(itemSelectedStub.lastCall.args[0].detail, {
trigger: 'tap', trigger: 'click',
selected: element.$.suggestions.querySelectorAll('li')[1], selected: element.$.suggestions.querySelectorAll('li')[1],
}); });
}); });
@@ -141,7 +141,7 @@ limitations under the License.
.lastElementChild); .lastElementChild);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.deepEqual(itemSelectedStub.lastCall.args[0].detail, { assert.deepEqual(itemSelectedStub.lastCall.args[0].detail, {
trigger: 'tap', trigger: 'click',
selected: element.$.suggestions.querySelectorAll('li')[0], selected: element.$.suggestions.querySelectorAll('li')[0],
}); });
}); });

View File

@@ -182,11 +182,11 @@
}, },
attached() { attached() {
this.listen(document.body, 'tap', '_handleBodyTap'); this.listen(document.body, 'click', '_handleBodyClick');
}, },
detached() { detached() {
this.unlisten(document.body, 'tap', '_handleBodyTap'); this.unlisten(document.body, 'click', '_handleBodyClick');
this.cancelDebouncer('update-suggestions'); this.cancelDebouncer('update-suggestions');
}, },
@@ -210,7 +210,7 @@
_handleItemSelect(e) { _handleItemSelect(e) {
// Let _handleKeydown deal with keyboard interaction. // Let _handleKeydown deal with keyboard interaction.
if (e.detail.trigger !== 'tap') { return; } if (e.detail.trigger !== 'click') { return; }
this._selected = e.detail.selected; this._selected = e.detail.selected;
this._commit(); this._commit();
}, },
@@ -374,7 +374,7 @@
} }
}, },
_handleBodyTap(e) { _handleBodyClick(e) {
const eventPath = Polymer.dom(e).path; const eventPath = Polymer.dom(e).path;
for (let i = 0; i < eventPath.length; i++) { for (let i = 0; i < eventPath.length; i++) {
if (eventPath[i] === this) { if (eventPath[i] === this) {

View File

@@ -30,7 +30,7 @@ limitations under the License.
fill: var(--link-color); fill: var(--link-color);
} }
</style> </style>
<button aria-label="Change star" on-tap="toggleStar"> <button aria-label="Change star" on-click="toggleStar">
<iron-icon <iron-icon
class$="[[_computeStarClass(change.starred)]]" class$="[[_computeStarClass(change.starred)]]"
icon$="[[_computeStarIcon(change.starred)]]"></iron-icon> icon$="[[_computeStarIcon(change.starred)]]"></iron-icon>

View File

@@ -51,7 +51,7 @@ limitations under the License.
class="copyText" class="copyText"
type="text" type="text"
bind-value="[[text]]" bind-value="[[text]]"
on-tap="_handleInputTap" on-tap="_handleInputClick"
readonly> readonly>
<input <input
id="input" id="input"
@@ -59,7 +59,7 @@ limitations under the License.
class$="[[_computeInputClass(hideInput)]]" class$="[[_computeInputClass(hideInput)]]"
type="text" type="text"
bind-value="[[text]]" bind-value="[[text]]"
on-tap="_handleInputTap" on-click="_handleInputClick"
readonly> readonly>
</iron-input> </iron-input>
<gr-button id="button" <gr-button id="button"

View File

@@ -43,7 +43,7 @@
return hideInput ? 'hideInput' : ''; return hideInput ? 'hideInput' : '';
}, },
_handleInputTap(e) { _handleInputClick(e) {
e.preventDefault(); e.preventDefault();
Polymer.dom(e).rootTarget.select(); Polymer.dom(e).rootTarget.select();
}, },

View File

@@ -65,7 +65,7 @@ limitations under the License.
element.$$('.copyToClipboard')); element.$$('.copyToClipboard'));
}); });
test('_handleInputTap', () => { test('_handleInputClick', () => {
const inputElement = element.$$('input'); const inputElement = element.$$('input');
MockInteractions.tap(inputElement); MockInteractions.tap(inputElement);
assert.equal(inputElement.selectionStart, 0); assert.equal(inputElement.selectionStart, 0);

View File

@@ -79,7 +79,7 @@ limitations under the License.
<label <label
class$="[[_computeLabelClass(readOnly, value, placeholder)]]" class$="[[_computeLabelClass(readOnly, value, placeholder)]]"
title$="[[_computeLabel(value, placeholder)]]" title$="[[_computeLabel(value, placeholder)]]"
on-tap="_showDropdown">[[_computeLabel(value, placeholder)]]</label> on-click="_showDropdown">[[_computeLabel(value, placeholder)]]</label>
<iron-dropdown id="dropdown" <iron-dropdown id="dropdown"
vertical-align="auto" vertical-align="auto"
horizontal-align="auto" horizontal-align="auto"

View File

@@ -97,7 +97,7 @@
this.listen(this._target, 'focus', 'show'); this.listen(this._target, 'focus', 'show');
this.listen(this._target, 'mouseleave', 'hide'); this.listen(this._target, 'mouseleave', 'hide');
this.listen(this._target, 'blur', 'hide'); this.listen(this._target, 'blur', 'hide');
this.listen(this._target, 'tap', 'hide'); this.listen(this._target, 'click', 'hide');
}, },
ready() { ready() {
@@ -118,7 +118,7 @@
this.unlisten(this._target, 'focus', 'show'); this.unlisten(this._target, 'focus', 'show');
this.unlisten(this._target, 'mouseleave', 'hide'); this.unlisten(this._target, 'mouseleave', 'hide');
this.unlisten(this._target, 'blur', 'hide'); this.unlisten(this._target, 'blur', 'hide');
this.unlisten(this._target, 'tap', 'hide'); this.unlisten(this._target, 'click', 'hide');
}, },
/** /**

View File

@@ -64,7 +64,7 @@ limitations under the License.
disabled="[[disabled]]" disabled="[[disabled]]"
placeholder="[[placeholder]]" placeholder="[[placeholder]]"
borderless></gr-autocomplete> borderless></gr-autocomplete>
<div id="trigger" on-tap="_handleTriggerTap"></div> <div id="trigger" on-click="_handleTriggerClick"></div>
</div> </div>
</div> </div>
</template> </template>

View File

@@ -58,7 +58,7 @@
}, },
}, },
_handleTriggerTap(e) { _handleTriggerClick(e) {
// Stop propagation here so we don't confuse gr-autocomplete, which // Stop propagation here so we don't confuse gr-autocomplete, which
// listens for taps on body to try to determine when it's blurred. // listens for taps on body to try to determine when it's blurred.
e.stopPropagation(); e.stopPropagation();

View File

@@ -49,7 +49,7 @@ limitations under the License.
const e = {stopPropagation: () => undefined}; const e = {stopPropagation: () => undefined};
sandbox.stub(e, 'stopPropagation'); sandbox.stub(e, 'stopPropagation');
sandbox.stub(element.$.autocomplete, 'focus'); sandbox.stub(element.$.autocomplete, 'focus');
element._handleTriggerTap(e); element._handleTriggerClick(e);
assert.isTrue(e.stopPropagation.calledOnce); assert.isTrue(e.stopPropagation.calledOnce);
assert.isTrue(element.$.autocomplete.focus.calledOnce); assert.isTrue(element.$.autocomplete.focus.calledOnce);
}); });