Commit 6e1cf7c2 authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI cr-toggle: Use native 'click' event instead of synthetic 'tap'.

Bug: 812035
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I3fefd8951f9c28b00e98f1a42edaa9d24e5e5856
Reviewed-on: https://chromium-review.googlesource.com/944045
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542269}
parent 346ac2e2
......@@ -26,7 +26,7 @@ Polymer({
},
listeners: {
'tap': 'onHostTap_',
'click': 'onHostTap_',
},
observers: [
......@@ -68,7 +68,7 @@ Polymer({
},
/**
* Handles non cr-toggle button taps (cr-toggle handles its own tap events
* Handles non cr-toggle button clicks (cr-toggle handles its own click events
* which don't bubble).
* @param {!Event} e
* @private
......
......@@ -115,7 +115,7 @@
</div>
</div>
<cr-toggle checked="[[unifiedDesktopMode_]]"
on-tap="onUnifiedDesktopTap_"
on-click="onUnifiedDesktopTap_"
aria-labelledby="displayUnifiedDesktopCheckboxLabel">
</cr-toggle>
</div>
......
......@@ -101,7 +101,7 @@
on-settings-boolean-control-change="onMetricsReportingChange_"
no-set-pref>
<template is="dom-if" if="[[showRestart_]]" restamp>
<paper-button on-tap="onRestartTap_" id="restart"
<paper-button on-click="onRestartTap_" id="restart"
slot="more-actions">
$i18n{restart}
</paper-button>
......
......@@ -25,8 +25,8 @@ Polymer({
},
listeners: {
'topMenu.tap': 'onLinkTap_',
'subMenu.tap': 'onLinkTap_',
'topMenu.click': 'onLinkTap_',
'subMenu.click': 'onLinkTap_',
},
/** @param {!settings.Route} newRoute */
......
......@@ -24,7 +24,7 @@
label="$i18n{hardwareAccelerationLabel}">
<template is="dom-if" if="[[shouldShowRestart_(
prefs.hardware_acceleration_mode.enabled.value)]]">
<paper-button on-tap="onRestartTap_" slot="more-actions">
<paper-button on-click="onRestartTap_" slot="more-actions">
$i18n{restart}
</paper-button>
</template>
......
......@@ -5,7 +5,7 @@
/**
* @fileoverview 'cr-toggle' is a component for showing an on/off switch. It
* fires a 'change' event *only* when its state changes as a result of a user
* interaction. Besides just tapping the element, its state can be changed by
* interaction. Besides just clicking the element, its state can be changed by
* dragging (pointerdown+pointermove) the element towards the desired direction.
*/
Polymer({
......@@ -40,7 +40,7 @@ Polymer({
listeners: {
'pointerdown': 'onPointerDown_',
'pointerup': 'onPointerUp_',
'tap': 'onTap_',
'click': 'onTap_',
'keypress': 'onKeyPress_',
'focus': 'onFocus_',
'blur': 'onBlur_',
......@@ -58,7 +58,7 @@ Polymer({
/**
* Whether the state of the toggle has already taken into account by
* |pointeremove| handlers. Used in the 'tap' handler.
* |pointeremove| handlers. Used in the 'click' handler.
* @private {boolean}
*/
handledInPointerMove_: false,
......@@ -136,28 +136,29 @@ Polymer({
/** @private */
onTap_: function(e) {
// Prevent |tap| event from bubbling. It can cause parents of this elements
// to erroneously re-toggle this control.
// Prevent |click| event from bubbling. It can cause parents of this
// elements to erroneously re-toggle this control.
e.stopPropagation();
e.preventDefault();
// User gesture has already been taken care of inside |pointermove|
// handlers, Do nothing here.
if (this.handledInPointerMove_)
return;
// If no pointermove event fired, then user just tapped on the
// If no pointermove event fired, then user just clicked on the
// toggle button and therefore it should be toggled.
this.toggleState_(false);
},
/**
* Whether the host of this element should handle a 'tap' event it received,
* to be used when tapping on the parent is supposed to toggle the cr-toggle.
* Whether the host of this element should handle a 'click' event it received,
* to be used when clicking on the parent is supposed to toggle the cr-toggle.
*
* This is necessary to avoid a corner case when pointerdown is initiated
* in cr-toggle, but pointerup happens outside the bounds of cr-toggle, which
* ends up firing a 'tap' event on the parent (see context at crbug.com/689158
* and crbug.com/768555).
* ends up firing a 'click' event on the parent (see context at
* crbug.com/689158 and crbug.com/768555).
* @param {!Event} e
* @return {boolean}
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment