Skip to content

Commit 92e38c1

Browse files
committed
fix(material/chips): fix click target when stacked
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 3703cc9 commit 92e38c1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,25 @@ <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"
258258
[value]="aColor.name">
259259
{{aColor.name}}
260+
<mat-icon matChipTrailingIcon>star</mat-icon>
261+
</mat-chip-option>
262+
</mat-chip-listbox>
263+
264+
The selected color is {{selectedColor}}.
265+
266+
<h4>Single selection with stacked appearance.</h4>
267+
268+
<mat-chip-listbox [(ngModel)]="selectedColor" class="mat-mdc-chip-set-stacked">
269+
<mat-chip-option *ngFor="let aColor of availableColors" [color]="aColor.color"
270+
[value]="aColor.name">
271+
{{aColor.name}}
272+
<mat-icon matChipTrailingIcon>star</mat-icon>
260273
</mat-chip-option>
261274
</mat-chip-listbox>
262275

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)