Commit 3e591d6c authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI cr-toggle: Fix corner case of calling click() when disabled.

When disabled, calling click() (which simulates a 'click' event) should not
change the state of the toggle.

Bug: None
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I2f1950c698fbc99abd7620d1573f592607f160e2
Reviewed-on: https://chromium-review.googlesource.com/1112719Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570144}
parent c6bd1218
......@@ -211,4 +211,20 @@ suite('cr-toggle', function() {
triggerPointerDownMoveUpTapSequence(0 /* no pointermove */);
assertChecked();
});
// Test that the control works as expected when the click() method is called.
test('ToggleWhenWithClick', function() {
assertNotDisabled();
assertNotChecked();
// State should change because control is enabled.
toggle.click();
assertChecked();
// State should *not* change because control is disabled.
toggle.disabled = true;
assertDisabled();
toggle.click();
assertChecked();
});
});
......@@ -137,6 +137,11 @@ Polymer({
e.stopPropagation();
e.preventDefault();
// Ignore case where 'click' handler is triggered while disabled. Can happen
// via calling the click() method.
if (this.disabled)
return;
// User gesture has already been taken care of inside |pointermove|
// handlers, Do nothing here.
if (this.handledInPointerMove_)
......
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