Skip to content

Commit ceb472b

Browse files
crisbetommalerba
authored andcommitted
fix(button): square ripple in compatibility mode (#3167)
* Fixes the ripple not being clipped in compatibility mode. The issue was due to the check not including the `mat-` selectors. * Reduces the amount of DOM manipulation done by the button. Fixes #3164.
1 parent 1f19ef0 commit ceb472b

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/lib/button/button.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<span class="mat-button-wrapper"><ng-content></ng-content></span>
22
<div md-ripple *ngIf="!_isRippleDisabled()" class="mat-button-ripple"
3-
[class.mat-button-ripple-round]="_isRoundButton()"
3+
[class.mat-button-ripple-round]="_isRoundButton"
44
[mdRippleTrigger]="_getHostElement()"></div>
55
<!-- the touchstart handler prevents the overlay from capturing the initial tap on touch devices -->
66
<div class="mat-button-focus-overlay" (touchstart)="$event.preventDefault()"></div>

src/lib/button/button.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ export class MdButton {
106106
/** Whether a mousedown has occurred on this element in the last 100ms. */
107107
_isMouseDown: boolean = false;
108108

109+
/** Whether the button is round. */
110+
_isRoundButton: boolean = ['icon-button', 'fab', 'mini-fab'].some(suffix => {
111+
let el = this._getHostElement();
112+
return el.hasAttribute('md-' + suffix) || el.hasAttribute('mat-' + suffix);
113+
});
114+
109115
/** Whether the ripple effect on click should be disabled. */
110116
private _disableRipple: boolean = false;
111117
private _disabled: boolean = null;
@@ -165,13 +171,6 @@ export class MdButton {
165171
return this._elementRef.nativeElement;
166172
}
167173

168-
_isRoundButton() {
169-
const el = this._getHostElement();
170-
return el.hasAttribute('md-icon-button') ||
171-
el.hasAttribute('md-fab') ||
172-
el.hasAttribute('md-mini-fab');
173-
}
174-
175174
_isRippleDisabled() {
176175
return this.disableRipple || this.disabled;
177176
}

0 commit comments

Comments
 (0)