Commit b240b381 authored by Roman Arora's avatar Roman Arora Committed by Commit Bot

CrIconButton: No ripple on focus capability

Bug: 1128599
Change-Id: I821f2adb8b13cdbd8d161a6b7cd75dc667cd7be6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450813
Commit-Queue: Roman Arora <romanarora@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815419}
parent f2d5b562
...@@ -67,4 +67,15 @@ suite('cr-icon-button-focus-tests', function() { ...@@ -67,4 +67,15 @@ suite('cr-icon-button-focus-tests', function() {
button.dispatchEvent(new PointerEvent('pointerdown')); button.dispatchEvent(new PointerEvent('pointerdown'));
assertTrue(button.hasRipple()); assertTrue(button.hasRipple());
}); });
test('when no-ripple-on-focus, no ripple on focus', () => {
button.noRippleOnFocus = false;
button.focus();
assertTrue(button.getRipple().holdDown);
button.blur();
button.noRippleOnFocus = true;
button.focus();
assertFalse(button.getRipple().holdDown);
});
}); });
...@@ -69,6 +69,11 @@ Polymer({ ...@@ -69,6 +69,11 @@ Polymer({
reflectToAttribute: true, reflectToAttribute: true,
}, },
noRippleOnFocus: {
type: Boolean,
value: false,
},
/** @private */ /** @private */
multipleIcons_: { multipleIcons_: {
type: Boolean, type: Boolean,
...@@ -93,7 +98,7 @@ Polymer({ ...@@ -93,7 +98,7 @@ Polymer({
blur: 'onBlur_', blur: 'onBlur_',
click: 'onClick_', click: 'onClick_',
down: 'showRipple_', down: 'showRipple_',
focus: 'showRipple_', focus: 'onFocus_',
keydown: 'onKeyDown_', keydown: 'onKeyDown_',
keyup: 'onKeyUp_', keyup: 'onKeyUp_',
pointerdown: 'ensureRipple', pointerdown: 'ensureRipple',
...@@ -155,10 +160,20 @@ Polymer({ ...@@ -155,10 +160,20 @@ Polymer({
this.setAttribute('tabindex', value); this.setAttribute('tabindex', value);
}, },
/** @private */
onFocus_() {
if (!this.noRippleOnFocus) {
this.showRipple_();
}
},
/** @private */ /** @private */
onBlur_() { onBlur_() {
this.spaceKeyDown_ = false; this.spaceKeyDown_ = false;
this.hideRipple_();
if (!this.noRippleOnFocus) {
this.hideRipple_();
}
}, },
/** /**
......
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