Skip to content

fix(material-experimental/mdc-button): always treat icon-button content as an icon #25200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/material-experimental/mdc-button/button-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ export class MatButtonBase
/** Whether this button is a FAB. Used to apply the correct class on the ripple. */
_isFab = false;

/** Whether this button is an icon button. Used to apply the correct class on the ripple. */
_isIconButton = false;

/** Reference to the MatRipple instance of the button. */
@ViewChild(MatRipple) ripple: MatRipple;

Expand Down
6 changes: 2 additions & 4 deletions src/material-experimental/mdc-button/button.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<span
class="mat-mdc-button-persistent-ripple"
[class.mdc-button__ripple]="!_isFab && !_isIconButton"
[class.mdc-fab__ripple]="_isFab"
[class.mdc-icon-button__ripple]="_isIconButton"></span>
[class.mdc-button__ripple]="!_isFab"
[class.mdc-fab__ripple]="_isFab"></span>

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

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

<span class="mat-mdc-button-touch-target"></span>
16 changes: 16 additions & 0 deletions src/material-experimental/mdc-button/icon-button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<span class="mat-mdc-button-persistent-ripple mdc-icon-button__ripple"></span>

<ng-content></ng-content>

<!--
The indicator can't be directly on the button, because MDC uses ::before for high contrast
indication and it can't be on the ripple, because it has a border radius and overflow: hidden.
-->
<span class="mat-mdc-focus-indicator"></span>

<span matRipple class="mat-mdc-button-ripple"
[matRippleDisabled]="_isRippleDisabled()"
[matRippleCentered]="true"
[matRippleTrigger]="_elementRef.nativeElement"></span>

<span class="mat-mdc-button-touch-target"></span>
6 changes: 1 addition & 5 deletions src/material-experimental/mdc-button/icon-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
*/
@Component({
selector: `button[mat-icon-button]`,
templateUrl: 'button.html',
templateUrl: 'icon-button.html',
styleUrls: ['icon-button.css', 'button-high-contrast.css'],
inputs: MAT_BUTTON_INPUTS,
host: MAT_BUTTON_HOST,
Expand All @@ -43,8 +43,6 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MatIconButton extends MatButtonBase {
override _isIconButton = true;

constructor(
elementRef: ElementRef,
platform: Platform,
Expand All @@ -71,8 +69,6 @@ export class MatIconButton extends MatButtonBase {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MatIconAnchor extends MatAnchorBase {
override _isIconButton = true;

constructor(
elementRef: ElementRef,
platform: Platform,
Expand Down