Skip to content

Commit 897062c

Browse files
committed
fix(button): accent color not set on fab buttons with build optimizer
When running an Angular application in production mode with the build optimizer and the Angular CLI, the code part, that sets the default color for round buttons, is removed accidentally. This seems to be an issue, that's caused by the build optimizer: angular/devkit#388. Fixes #9360
1 parent 60b0625 commit 897062c

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

src/demo-app/button/button-demo.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
<section>
33
<button mat-button>flat</button>
44
<button mat-raised-button>raised</button>
5-
<button mat-fab>
6-
<mat-icon>check</mat-icon>
7-
</button>
8-
<button mat-fab>Btn</button>
9-
<a mat-fab routerLink=".">Link</a>
5+
6+
<button mat-fab><mat-icon>check</mat-icon></button>
7+
<button mat-fab color="primary">Btn</button>
8+
<a mat-fab color="warn" routerLink=".">Link</a>
109
<a mat-fab routerLink="."><mat-icon>check</mat-icon></a>
11-
<button mat-mini-fab>
12-
<mat-icon>check</mat-icon>
13-
</button>
14-
<button mat-mini-fab>Btn</button>
15-
<a mat-mini-fab routerLink=".">Link</a>
10+
11+
<button mat-mini-fab><mat-icon>check</mat-icon></button>
12+
<button mat-mini-fab color="primary">Btn</button>
13+
<a mat-mini-fab color="warn" routerLink=".">Link</a>
14+
<a mat-mini-fab routerLink="."><mat-icon>check</mat-icon></a>
1615
</section>
1716

1817
<section>

src/lib/button/button.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,30 +74,17 @@ export class MatIconButtonCssMatStyler {}
7474
selector: 'button[mat-fab], a[mat-fab]',
7575
host: {'class': 'mat-fab'}
7676
})
77-
export class MatFab {
78-
constructor(@Self() @Optional() @Inject(forwardRef(() => MatButton)) button: MatButton,
79-
@Self() @Optional() @Inject(forwardRef(() => MatAnchor)) anchor: MatAnchor) {
80-
// Set the default color palette for the mat-fab components.
81-
(button || anchor).color = DEFAULT_ROUND_BUTTON_COLOR;
82-
}
83-
}
77+
export class MatFab {}
8478

8579
/**
86-
* Directive that targets mini-fab buttons and anchors. It's used to apply the `mat-` class
87-
* to all mini-fab buttons and also is responsible for setting the default color palette.
80+
* Directive whose purpose is to add the mat- CSS styling to this selector.
8881
* @docs-private
8982
*/
9083
@Directive({
9184
selector: 'button[mat-mini-fab], a[mat-mini-fab]',
9285
host: {'class': 'mat-mini-fab'}
9386
})
94-
export class MatMiniFab {
95-
constructor(@Self() @Optional() @Inject(forwardRef(() => MatButton)) button: MatButton,
96-
@Self() @Optional() @Inject(forwardRef(() => MatAnchor)) anchor: MatAnchor) {
97-
// Set the default color palette for the mat-mini-fab components.
98-
(button || anchor).color = DEFAULT_ROUND_BUTTON_COLOR;
99-
}
100-
}
87+
export class MatMiniFab {}
10188

10289

10390
// Boilerplate for applying mixins to MatButton.
@@ -139,7 +126,12 @@ export class MatButton extends _MatButtonMixinBase
139126
private _platform: Platform,
140127
private _focusMonitor: FocusMonitor) {
141128
super(elementRef);
129+
142130
this._focusMonitor.monitor(this._elementRef.nativeElement, true);
131+
132+
if (this._isRoundButton) {
133+
this.color = DEFAULT_ROUND_BUTTON_COLOR;
134+
}
143135
}
144136

145137
ngOnDestroy() {

0 commit comments

Comments
 (0)