Skip to content

Commit a9c7f59

Browse files
committed
fix(material-experimental/mdc-button): always treat icon-button content as an icon (#25200)
(cherry picked from commit 22cb07b)
1 parent 76c0e9c commit a9c7f59

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

src/material-experimental/mdc-button/button-base.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ export class MatButtonBase
8888
/** Whether this button is a FAB. Used to apply the correct class on the ripple. */
8989
_isFab = false;
9090

91-
/** Whether this button is an icon button. Used to apply the correct class on the ripple. */
92-
_isIconButton = false;
93-
9491
/** Reference to the MatRipple instance of the button. */
9592
@ViewChild(MatRipple) ripple: MatRipple;
9693

src/material-experimental/mdc-button/button.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<span
22
class="mat-mdc-button-persistent-ripple"
3-
[class.mdc-button__ripple]="!_isFab && !_isIconButton"
4-
[class.mdc-fab__ripple]="_isFab"
5-
[class.mdc-icon-button__ripple]="_isIconButton"></span>
3+
[class.mdc-button__ripple]="!_isFab"
4+
[class.mdc-fab__ripple]="_isFab"></span>
65

76
<ng-content select=".material-icons:not([iconPositionEnd]), mat-icon:not([iconPositionEnd])">
87
</ng-content>
@@ -20,7 +19,6 @@
2019

2120
<span matRipple class="mat-mdc-button-ripple"
2221
[matRippleDisabled]="_isRippleDisabled()"
23-
[matRippleCentered]="_isIconButton"
2422
[matRippleTrigger]="_elementRef.nativeElement"></span>
2523

2624
<span class="mat-mdc-button-touch-target"></span>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<span class="mat-mdc-button-persistent-ripple mdc-icon-button__ripple"></span>
2+
3+
<ng-content></ng-content>
4+
5+
<!--
6+
The indicator can't be directly on the button, because MDC uses ::before for high contrast
7+
indication and it can't be on the ripple, because it has a border radius and overflow: hidden.
8+
-->
9+
<span class="mat-mdc-focus-indicator"></span>
10+
11+
<span matRipple class="mat-mdc-button-ripple"
12+
[matRippleDisabled]="_isRippleDisabled()"
13+
[matRippleCentered]="true"
14+
[matRippleTrigger]="_elementRef.nativeElement"></span>
15+
16+
<span class="mat-mdc-button-touch-target"></span>

src/material-experimental/mdc-button/icon-button.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
*/
3535
@Component({
3636
selector: `button[mat-icon-button]`,
37-
templateUrl: 'button.html',
37+
templateUrl: 'icon-button.html',
3838
styleUrls: ['icon-button.css', 'button-high-contrast.css'],
3939
inputs: MAT_BUTTON_INPUTS,
4040
host: MAT_BUTTON_HOST,
@@ -43,8 +43,6 @@ import {
4343
changeDetection: ChangeDetectionStrategy.OnPush,
4444
})
4545
export class MatIconButton extends MatButtonBase {
46-
override _isIconButton = true;
47-
4846
constructor(
4947
elementRef: ElementRef,
5048
platform: Platform,
@@ -71,8 +69,6 @@ export class MatIconButton extends MatButtonBase {
7169
changeDetection: ChangeDetectionStrategy.OnPush,
7270
})
7371
export class MatIconAnchor extends MatAnchorBase {
74-
override _isIconButton = true;
75-
7672
constructor(
7773
elementRef: ElementRef,
7874
platform: Platform,

0 commit comments

Comments
 (0)