Skip to content

Commit de0bb5c

Browse files
fix(chips): add truncation support
PiperOrigin-RevId: 648545115
1 parent 352607d commit de0bb5c

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

chips/internal/_shared.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
height: var(--_container-height);
2323
cursor: pointer;
2424
-webkit-tap-highlight-color: transparent;
25+
max-width: 100%;
2526

2627
@include ripple.theme(
2728
(
@@ -96,6 +97,9 @@
9697
}
9798

9899
.primary.action {
100+
// Set a min-width on the primary action so that trailing actions remain
101+
// inside the chip as the chip is resized.
102+
min-width: 0;
99103
padding-inline-start: var(--_leading-space);
100104
padding-inline-end: var(--_trailing-space);
101105
}
@@ -151,11 +155,16 @@
151155
display: flex;
152156
font-family: var(--_label-text-font);
153157
font-size: var(--_label-text-size);
154-
line-height: var(--_label-text-line-height);
155158
font-weight: var(--_label-text-weight);
156159
height: 100%;
157-
text-overflow: ellipsis;
160+
line-height: var(--_label-text-line-height);
161+
overflow: hidden;
158162
user-select: none;
163+
}
164+
165+
.label-text {
166+
overflow: hidden;
167+
text-overflow: ellipsis;
159168
white-space: nowrap;
160169
}
161170

chips/internal/chip.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ export abstract class Chip extends LitElement {
129129
<span class="leading icon" aria-hidden="true">
130130
${this.renderLeadingIcon()}
131131
</span>
132-
<span class="label">${this.label}</span>
132+
<span class="label">
133+
<span class="label-text">${this.label}</span>
134+
</span>
133135
<span class="touch"></span>
134136
`;
135137
}

testing/table/internal/test-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class TestTable<S extends string = string> extends LitElement {
8282
</th>
8383
${this.states.map(
8484
(state, colIndex) => html`
85-
<td class="md3-test-table__cell">
85+
<td class="md3-test-table__cell" part="cell">
8686
<slot name="${`${rowIndex}-${colIndex}`}">
8787
<div class="md3-test-table__text">N/A</div>
8888
</slot>

0 commit comments

Comments
 (0)