Skip to content

Commit 2c07867

Browse files
authored
fix(material/chips): fix click target when stacked (#27129)
Ensure that the click target of stacked chips is the entire width of the chip. Fix issue where applying .mat-mdc-chip-set-stacked causes chips to respond to clicks when clicking on the text; did not respond when clicking inside the chip but not over the text (#26590). Ensure the clickable elemen tof the chip takes up the whole visual area of the chip by overriding styles from MDC library. Angular Material supports vertically-stacked chips, which MDC does not. Fix #26590
1 parent 3749308 commit 2c07867

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h4>NgModel with single selection</h4>
251251

252252
The selected color is {{selectedColor}}.
253253

254-
<h4>Single selection without checkmark indicator.</h4>
254+
<h4>Single selection without checkmark selection indicator.</h4>
255255

256256
<mat-chip-listbox [(ngModel)]="selectedColor" [hideSingleSelectionIndicator]="true">
257257
<mat-chip-option *ngFor="let aColor of availableColors" [color]="aColor.color"
@@ -260,6 +260,29 @@ <h4>Single selection without checkmark indicator.</h4>
260260
</mat-chip-option>
261261
</mat-chip-listbox>
262262

263+
<h4>Single selection with decorative icons.</h4>
264+
265+
<mat-chip-listbox [(ngModel)]="selectedColor" [hideSingleSelectionIndicator]="true">
266+
<mat-chip-option *ngFor="let aColor of availableColors" [color]="aColor.color"
267+
[value]="aColor.name">
268+
<mat-icon matChipAvatar>home</mat-icon>
269+
{{aColor.name}}
270+
<mat-icon matChipTrailingIcon>star</mat-icon>
271+
</mat-chip-option>
272+
</mat-chip-listbox>
273+
274+
The selected color is {{selectedColor}}.
275+
276+
<h4>Single selection with stacked appearance.</h4>
277+
278+
<mat-chip-listbox [(ngModel)]="selectedColor" class="mat-mdc-chip-set-stacked">
279+
<mat-chip-option *ngFor="let aColor of availableColors" [color]="aColor.color"
280+
[value]="aColor.name">
281+
{{aColor.name}}
282+
<mat-icon matChipTrailingIcon>star</mat-icon>
283+
</mat-chip-option>
284+
</mat-chip-listbox>
285+
263286
The selected color is {{selectedColor}}.
264287
</mat-card-content>
265288
</mat-card>

src/material/chips/chip-set.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
.mat-mdc-chip {
2020
width: 100%;
2121
}
22+
23+
.mdc-evolution-chip__graphic {
24+
flex-grow: 0;
25+
}
26+
27+
.mdc-evolution-chip__action--primary {
28+
flex-basis: 100%;
29+
justify-content: start;
30+
}
2231
}
2332

2433
input.mat-mdc-chip-input {

0 commit comments

Comments
 (0)