Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit ad3bbf7

Browse files
patrickrodeecopybara-github
authored andcommitted
fix(chips): Move touch target inside primary action
BREAKING CHANGE: The touch target and text now appear inside the primary action element. Please see the readme for markup changes. PiperOrigin-RevId: 294259413
1 parent 559f1a5 commit ad3bbf7

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

packages/mdc-chips/README.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@ npm install @material/chips
4646
<div class="mdc-chip" role="row">
4747
<div class="mdc-chip__ripple"></div>
4848
<span role="gridcell">
49-
<span role="button" tabindex="0" class="mdc-chip__text">Chip One</span>
49+
<span role="button" tabindex="0" class="mdc-chip__primary-action">
50+
<span class="mdc-chip__text">Chip One</span>
51+
</span>
5052
</span>
5153
</div>
5254
<div class="mdc-chip" role="row">
5355
<div class="mdc-chip__ripple"></div>
5456
<span role="gridcell">
55-
<span role="button" tabindex="-1" class="mdc-chip__text">Chip Two</span>
57+
<span role="button" tabindex="-1" class="mdc-chip__primary-action">
58+
<span class="mdc-chip__text">Chip Two</span>
59+
</span>
5660
</span>
5761
</div>
5862
...
@@ -98,7 +102,9 @@ However, you can also use SVG, [Font Awesome](https://fontawesome.com/), or any
98102
<div class="mdc-chip__ripple"></div>
99103
<i class="material-icons mdc-chip__icon mdc-chip__icon--leading">event</i>
100104
<span role="gridcell">
101-
<span role="button" tabindex="0" class="mdc-chip__text">Add to calendar</span>
105+
<span role="button" tabindex="0" class="mdc-chip__primary-action">
106+
<span class="mdc-chip__text">Add to calendar</span>
107+
</span>
102108
</span>
103109
</div>
104110
```
@@ -111,7 +117,9 @@ A trailing icon comes with the functionality to remove the chip from the set. If
111117
<div class="mdc-chip" role="row">
112118
<div class="mdc-chip__ripple"></div>
113119
<span role="gridcell">
114-
<span role="button" tabindex="0" class="mdc-chip__text">Jane Smith</span>
120+
<span role="button" tabindex="0" class="mdc-chip__primary-action">
121+
<span class="mdc-chip__text">Jane Smith</span>
122+
</span>
115123
</span>
116124
<span role="gridcell">
117125
<i class="material-icons mdc-chip__icon mdc-chip__icon--trailing" tabindex="-1" role="button">cancel</i>
@@ -144,9 +152,11 @@ Filter chips are a variant of chips which allow multiple selection from a set of
144152
</svg>
145153
</span>
146154
<span role="gridcell">
147-
<span role="checkbox" tabindex="0" aria-checked="false" class="mdc-chip__text">Filterable content</span>
155+
<span role="checkbox" tabindex="0" aria-checked="false" class="mdc-chip__primary-action">
156+
<span class="mdc-chip__text">Filterable content</span>
157+
</span>
148158
</span>
149-
</button>
159+
</div>
150160
...
151161
</div>
152162
```
@@ -165,7 +175,9 @@ To use a leading icon in a filter chip, put the `mdc-chip__icon--leading` elemen
165175
</svg>
166176
</span>
167177
<span role="gridcell">
168-
<span role="checkbox" tabindex="0" aria-checked="false" class="mdc-chip__text">Filterable content</span>
178+
<span role="checkbox" tabindex="0" aria-checked="false" class="mdc-chip__primary-action">
179+
<span class="mdc-chip__text">Filterable content</span>
180+
</span>
169181
</span>
170182
</div>
171183
...
@@ -223,7 +235,9 @@ To display a pre-selected filter or choice chip, add the class `mdc-chip--select
223235
<div class="mdc-chip mdc-chip--selected" role="row">
224236
<div class="mdc-chip__ripple"></div>
225237
<span role="gridcell">
226-
<span role="radio" tabindex="0" aria-checked="true" class="mdc-chip__text">Add to calendar</span>
238+
<span role="radio" tabindex="0" aria-checked="true" class="mdc-chip__primary-action">
239+
<span class="mdc-chip__text">Add to calendar</span>
240+
</span>
227241
</span>
228242
</div>
229243
</div>
@@ -243,7 +257,9 @@ To pre-select filter chips that have a leading icon, also add the class `mdc-chi
243257
</svg>
244258
</span>
245259
<span role="gridcell">
246-
<span role="checkbox" tabindex="0" aria-checked="true" class="mdc-chip__text">Filterable content</span>
260+
<span role="checkbox" tabindex="0" aria-checked="true" class="mdc-chip__primary-action">
261+
<span class="mdc-chip__text">Filterable content</span>
262+
</span>
247263
</span>
248264
</div>
249265
</div>
@@ -258,13 +274,15 @@ To meet this requirement, add the following to your chip:
258274

259275
```html
260276
<div class="mdc-touch-target-wrapper">
261-
<button class="mdc-chip mdc-chip--touch">
277+
<div class="mdc-chip mdc-chip--touch">
262278
<div class="mdc-chip__ripple"></div>
263279
<span role="gridcell">
264-
<span role="button" tabindex="0" class="mdc-chip__text">Chip One</span>
280+
<span role="button" tabindex="0" class="mdc-chip__primary-action">
281+
<div class="mdc-chip__touch"></div>
282+
<span class="mdc-chip__text">Chip One</span>
283+
</span>
265284
</span>
266-
<div class="mdc-chip__touch"></div>
267-
</button>
285+
</div>
268286
</div>
269287
```
270288

packages/mdc-chips/_mixins.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ $ripple-target: ".mdc-chip__ripple";
146146
}
147147
}
148148

149-
.mdc-chip__text:focus {
149+
.mdc-chip__primary-action:focus {
150150
@include feature-targeting-mixins.targets($feat-structure) {
151151
outline: none;
152152
}

packages/mdc-chips/chip/test/component.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ const getFixture = () => {
3333
wrapper.innerHTML = `
3434
<div class="mdc-chip" role="row">
3535
<span role="gridcell">
36-
<span role="button" tabindex="0" class="mdc-chip__text mdc-chip__primary-action">Chip content</span>
36+
<span role="button" tabindex="0" class="mdc-chip__primary-action">
37+
<span class="mdc-chip__text">Chip content</span>
38+
</span>
3739
</span>
3840
</div>`;
3941

@@ -53,8 +55,8 @@ const getFixtureWithCheckmark = () => {
5355
</svg>
5456
</div>
5557
<span role="gridcell">
56-
<span role="checkbox" aria-checked="false" tabindex="0" class="mdc-chip__text mdc-chip__primary-action">
57-
Chip content
58+
<span role="checkbox" aria-checked="false" tabindex="0" class="mdc-chip__primary-action">
59+
<span class="mdc-chip__text">Chip content</span>
5860
</span>
5961
</span>
6062
</div>`;

0 commit comments

Comments
 (0)