Skip to content

Commit 7bd738f

Browse files
committed
fix(material/chips): implement touch-target pattern/styles on chip component
Updates Angular Components' Chip component so that chips use a touch-target span similar to other interactive components like buttons and checkboxes. This is to ensure that chips meet the minimum touch-target size of 48x48 for accessibility standards. Fixes b/537441584
1 parent 5fcd952 commit 7bd738f

8 files changed

Lines changed: 26 additions & 3 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919

2020
.mat-mdc-basic-chip {
21-
margin: auto 10px;
21+
margin: 16px 10px;
2222
}
2323

2424
mat-chip-grid input {

src/material/chips/_m2-chip.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
@function get-tokens($theme) {
77
$system: m2-utils.get-system($theme);
88
$density-scale: theming.clamp-density(map.get($system, density-scale), -2);
9+
$touch-target-display: block;
10+
11+
@if $density-scale < 0 {
12+
$touch-target-display: none;
13+
}
914

1015
@return (
1116
base: (
@@ -43,7 +48,8 @@
4348
chip-container-height: map.get((
4449
0: 32px,
4550
-1: 28px,
46-
-2: 24px), $density-scale)
51+
-2: 24px), $density-scale),
52+
chip-touch-target-display: $touch-target-display,
4753
),
4854
);
4955
}

src/material/chips/_m3-chip.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@
7777

7878
@return (
7979
chip-container-height: list.nth((32px, 28px, 24px), $index),
80+
chip-touch-target-display: list.nth((block, none, none), $index),
8081
);
8182
}

src/material/chips/chip-option.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<span class="mdc-evolution-chip__text-label mat-mdc-chip-action-label">
2727
<ng-content></ng-content>
2828
<span class="mat-mdc-chip-primary-focus-indicator mat-focus-indicator"></span>
29+
<span class="mat-mdc-chip-touch-target"></span>
2930
</span>
3031
</button>
3132
</span>

src/material/chips/chip-row.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
<span class="mat-mdc-chip-primary-focus-indicator mat-focus-indicator" aria-hidden="true"></span>
3333
</span>
34+
<span class="mat-mdc-chip-touch-target"></span>
3435
</span>
3536

3637
@if (_hasTrailingIcon()) {

src/material/chips/chip-set.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717

1818
.mdc-evolution-chip {
19-
margin: 4px 0 4px 8px;
19+
margin: 8px 0 8px 8px;
2020
}
2121

2222
[dir='rtl'] & {

src/material/chips/chip.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<ng-content></ng-content>
1212
<span class="mat-mdc-chip-primary-focus-indicator mat-focus-indicator"></span>
1313
</span>
14+
<span class="mat-mdc-chip-touch-target"></span>
1415
</span>
1516
</span>
1617

src/material/chips/chip.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ $_graphic-padding: 6px;
1212
$_trailing-action-padding: 8px;
1313
$_avatar-leading-padding: 4px;
1414
$_avatar-trailing-padding: 8px;
15+
$_touch-target-size: 48px;
1516

1617
$fallbacks: m3-chip.get-tokens();
1718

@@ -27,6 +28,18 @@ $fallbacks: m3-chip.get-tokens();
2728
max-width: 100%;
2829
}
2930

31+
.mat-mdc-chip-touch-target {
32+
position: absolute;
33+
top: 50%;
34+
left: 0;
35+
right: 0;
36+
height: $_touch-target-size;
37+
transform: translateY(-50%);
38+
display: token-utils.slot(chip-touch-target-display, $fallbacks);
39+
pointer-events: auto;
40+
outline: 1px solid purple;
41+
}
42+
3043
.mdc-evolution-chip__cell,
3144
.mdc-evolution-chip__action {
3245
height: 100%;

0 commit comments

Comments
 (0)