Skip to content

Commit b405355

Browse files
[DataTable] Fix dom validation error, focus states and icon shimmering. (#6722)
* DataTable: Update invalid DOM, Fix icon shimmering, improve fixed header * Added changeset * Update .changeset/odd-games-cough.md Co-authored-by: Chloe Rice <[email protected]>
1 parent 03b5909 commit b405355

File tree

7 files changed

+505
-120
lines changed

7 files changed

+505
-120
lines changed

.changeset/odd-games-cough.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@shopify/polaris': patch
3+
'polaris.shopify.com': patch
4+
---
5+
6+
---
7+
8+
## '@shopify/polaris': patch
9+
10+
- Updated `DataTable` to fix console warning about improperly nested HTML
11+
- Updated `DataTable` to ensure focus states remain on the same header element when switching between sticky and regular header.
12+
- Improved `DataTable` tooltip when using `truncate` prop.

polaris-react/src/components/DataTable/DataTable.scss

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
align-items: center;
1313
justify-content: center;
1414
width: 100%;
15-
padding: var(--p-space-4) var(--p-space-2);
15+
padding: var(--p-space-4) var(--p-space-2) 0;
1616

1717
@media #{$p-breakpoints-md-up} {
1818
justify-content: flex-end;
@@ -165,8 +165,7 @@
165165
display: flex;
166166
align-self: flex-end;
167167
opacity: 0;
168-
transition: opacity var(--p-duration-200) var(--p-ease),
169-
fill var(--p-duration-200) var(--p-ease);
168+
transition: opacity var(--p-duration-200) var(--p-ease);
170169
}
171170

172171
.Heading {
@@ -176,7 +175,7 @@
176175
display: inline-flex;
177176
justify-content: flex-end;
178177
align-items: baseline;
179-
@include recolor-icon(var(--p-icon));
178+
@include recolor-icon(var(--p-icon-disabled));
180179
color: var(--p-text);
181180
transition: color var(--p-duration-200) var(--p-ease);
182181
cursor: pointer;
@@ -187,7 +186,7 @@
187186
visibility: hidden;
188187
}
189188

190-
.StickyHeaderEnabled [data-sticky-active] .StickyTable & {
189+
.StickyHeaderEnabled [data-sticky-active] .StickyHeaderWrapper & {
191190
visibility: visible;
192191
}
193192

@@ -200,15 +199,10 @@
200199
}
201200

202201
&:hover {
203-
@include recolor-icon(var(--p-interactive-hovered));
204202
color: var(--p-interactive-hovered);
205203

206204
.Icon {
207205
opacity: 1;
208-
209-
svg {
210-
fill: var(--p-icon-disabled);
211-
}
212206
}
213207
}
214208

@@ -233,6 +227,11 @@
233227
.Cell-sorted {
234228
.Icon {
235229
opacity: 1;
230+
@include recolor-icon(var(--p-icon));
231+
}
232+
233+
&:hover {
234+
@include recolor-icon(var(--p-interactive-hovered));
236235
}
237236

238237
.Heading:focus:not(:active) {
@@ -285,7 +284,7 @@
285284
}
286285

287286
.StickyHeaderEnabled {
288-
.StickyTable {
287+
.StickyHeaderWrapper {
289288
position: relative;
290289
top: 0;
291290
left: 0;
@@ -294,28 +293,25 @@
294293
z-index: var(--p-z-1);
295294
}
296295

297-
.StickyTableHeader {
296+
.StickyHeaderInner {
298297
position: absolute;
299298
display: flex;
300299
flex-direction: column;
301300
width: 100%;
302301
overflow: hidden;
303302
border-spacing: 0;
304303

305-
&:not(.StickyTableHeader-isSticky) {
304+
&:not(.StickyHeaderInner-isSticky) {
306305
top: -9999px;
307306
left: -9999px;
308307
}
309308
}
310309

311-
.StickyTableColumnHeader-isScrolling {
312-
box-shadow: 1px 1px 0 0 var(--p-border-divider),
313-
1px 0 1px 1px rgba(63, 63, 68, 0.05), 1px 0 3px 0 rgba(63, 63, 68, 0.15);
314-
}
315-
316-
.StickyTableHeadingsRow {
310+
.StickyHeaderTable {
311+
border-collapse: collapse;
312+
display: block;
317313
overflow-x: auto;
318-
background-color: var(--p-surface);
314+
width: 100%;
319315
scrollbar-width: none;
320316

321317
&::-webkit-scrollbar {
@@ -325,7 +321,16 @@
325321
}
326322
}
327323

328-
.StickyTableHeader-isSticky {
324+
.StickyTableColumnHeader-isScrolling {
325+
box-shadow: 1px 1px 0 0 var(--p-border-divider),
326+
1px 0 1px 1px rgba(63, 63, 68, 0.05), 1px 0 3px 0 rgba(63, 63, 68, 0.15);
327+
}
328+
329+
.StickyTableHeadingsRow {
330+
background-color: var(--p-surface);
331+
}
332+
333+
.StickyHeaderInner-isSticky {
329334
visibility: visible;
330335
background-color: var(--p-surface);
331336
box-shadow: var(--p-shadow-base);
@@ -337,11 +342,13 @@
337342
background: var(--p-surface);
338343
z-index: 3;
339344
border-spacing: 0;
345+
left: 0;
340346
@media #{$p-breakpoints-md-down} {
341347
z-index: 1;
342348
}
343349

344-
&.separate th {
350+
&.separate:is(table) th,
351+
&.separate:is(th) {
345352
border-right: var(--p-border-divider);
346353
}
347354
}

0 commit comments

Comments
 (0)