Skip to content

Commit 60e0d88

Browse files
devversionandrewseguin
authored andcommitted
fix(chips): disabled state not matching specs (#13272)
* Currently if chips are disabled with the spec 2018 alignment, it's not clear whether a chip is disabled or not. The chip still has a focus effect, hover effect and pointer cursor for the `mat-chip-remove`. * Also moves the `@include mat-elevation` to the theme (probably introduced before: #11344 has been merged)
1 parent e31e011 commit 60e0d88

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

src/demo-app/chips/chips-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h4>With avatar and icons</h4>
3636

3737

3838
<mat-chip-list>
39-
<mat-chip>
39+
<mat-chip disabled>
4040
<mat-icon matChipAvatar>home</mat-icon>
4141
Home
4242
<mat-icon matChipRemove>cancel</mat-icon>

src/lib/chips/_chips-theme.scss

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ $mat-chip-remove-font-size: 18px;
1313
color: $foreground;
1414
opacity: 0.4;
1515
}
16-
17-
.mat-chip-remove:hover {
18-
opacity: 0.54;
19-
}
2016
}
2117

2218
@mixin mat-chips-theme-color($palette) {
@@ -38,12 +34,21 @@ $mat-chip-remove-font-size: 18px;
3834
$unselected-background: mat-color($background, unselected-chip);
3935
$unselected-foreground: mat-color($foreground, text);
4036

41-
4237
.mat-chip.mat-standard-chip {
4338
@include mat-chips-color($unselected-foreground, $unselected-background);
4439

45-
&:focus {
46-
@include _mat-theme-elevation(3, $theme);
40+
&:not(.mat-chip-disabled) {
41+
&:active {
42+
@include _mat-theme-elevation(3, $theme);
43+
}
44+
45+
.mat-chip-remove:hover {
46+
opacity: 0.54;
47+
}
48+
}
49+
50+
&.mat-chip-disabled {
51+
opacity: 0.4;
4752
}
4853
}
4954

src/lib/chips/chips.scss

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ $mat-chip-remove-size: 18px;
7676
}
7777
}
7878

79-
&:active {
80-
@include mat-elevation(3);
81-
}
82-
8379
@include cdk-high-contrast {
8480
outline: solid 1px;
8581

@@ -89,6 +85,17 @@ $mat-chip-remove-size: 18px;
8985
}
9086
}
9187

88+
&.mat-chip-disabled {
89+
&::after {
90+
opacity: 0;
91+
}
92+
93+
.mat-chip-remove,
94+
.mat-chip-trailing-icon {
95+
cursor: default;
96+
}
97+
}
98+
9299
&.mat-chip-with-trailing-icon.mat-chip-with-avatar,
93100
&.mat-chip-with-avatar {
94101
padding-top: $mat-chip-avatar-vertical-padding;

0 commit comments

Comments
 (0)