Skip to content

Commit af27018

Browse files
fix(table): adds extra block borders for row focus
1 parent 6d8138d commit af27018

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

components/table/dist/metadata.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@
8383
".spectrum-Table-row.is-drop-target .spectrum-Table-cell",
8484
".spectrum-Table-row.is-drop-target .spectrum-Table-checkbox .spectrum-Checkbox-box:before",
8585
".spectrum-Table-row.is-focused",
86+
".spectrum-Table-row.is-focused .spectrum-Table-cell",
8687
".spectrum-Table-row.is-focused .spectrum-Table-cell:first-child",
8788
".spectrum-Table-row.is-focused .spectrum-Table-cell:first-child:before",
89+
".spectrum-Table-row.is-focused .spectrum-Table-cell:last-child",
8890
".spectrum-Table-row.is-focused .spectrum-Table-checkbox .spectrum-Checkbox-box:before",
91+
".spectrum-Table-row.is-focused:first-child .spectrum-Table-cell",
92+
".spectrum-Table-row.is-focused:last-child .spectrum-Table-cell",
8993
".spectrum-Table-row.is-focused:last-child .spectrum-Table-cell:first-child:before",
9094
".spectrum-Table-row.is-selected",
9195
".spectrum-Table-row.is-selected .spectrum-Table-checkbox .spectrum-Checkbox-box:before",
@@ -95,13 +99,22 @@
9599
".spectrum-Table-row:active",
96100
".spectrum-Table-row:first-child",
97101
".spectrum-Table-row:first-child .spectrum-Table-cell:last-child",
102+
".spectrum-Table-row:focus",
103+
".spectrum-Table-row:focus .spectrum-Table-cell",
98104
".spectrum-Table-row:focus .spectrum-Table-cell:first-child",
99105
".spectrum-Table-row:focus .spectrum-Table-cell:first-child:before",
106+
".spectrum-Table-row:focus .spectrum-Table-cell:last-child",
100107
".spectrum-Table-row:focus-visible",
108+
".spectrum-Table-row:focus-visible .spectrum-Table-cell",
101109
".spectrum-Table-row:focus-visible .spectrum-Table-cell:first-child",
102110
".spectrum-Table-row:focus-visible .spectrum-Table-cell:first-child:before",
111+
".spectrum-Table-row:focus-visible .spectrum-Table-cell:last-child",
103112
".spectrum-Table-row:focus-visible .spectrum-Table-checkbox .spectrum-Checkbox-box:before",
113+
".spectrum-Table-row:focus-visible:first-child .spectrum-Table-cell",
114+
".spectrum-Table-row:focus-visible:last-child .spectrum-Table-cell",
104115
".spectrum-Table-row:focus-visible:last-child .spectrum-Table-cell:first-child:before",
116+
".spectrum-Table-row:focus:first-child .spectrum-Table-cell",
117+
".spectrum-Table-row:focus:last-child .spectrum-Table-cell",
105118
".spectrum-Table-row:focus:last-child .spectrum-Table-cell:first-child:before",
106119
".spectrum-Table-row:hover",
107120
".spectrum-Table-row:hover .spectrum-Table-cell:first-child:before",
@@ -279,6 +292,7 @@
279292
"--spectrum-table-row-checkbox-to-top-medium-compact",
280293
"--spectrum-table-row-checkbox-to-top-medium-spacious",
281294
"--spectrum-table-row-down-opacity",
295+
"--spectrum-table-row-focus-indicator-outline-width",
282296
"--spectrum-table-row-focus-indicator-width",
283297
"--spectrum-table-row-font-family",
284298
"--spectrum-table-row-font-size",

components/table/index.css

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
--spectrum-table-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness);
5050
--spectrum-table-focus-indicator-color: var(--spectrum-focus-indicator-color);
5151
--spectrum-table-row-focus-indicator-width: var(--spectrum-side-focus-indicator);
52+
--spectrum-table-row-focus-indicator-outline-width: 1px;
5253

5354
--spectrum-table-selected-cell-background-color-focus: var(--highcontrast-table-selected-row-background-color-focus, var(--mod-table-selected-row-background-color-non-emphasized-focus, var(--spectrum-table-selected-row-background-color-non-emphasized-focus)));
5455

@@ -485,11 +486,15 @@
485486
&.is-focused,
486487
&:focus-visible,
487488
&:focus {
489+
outline: none;
490+
491+
/* First cell of focused rows need fancy new focus indicator borders & no border-radius, and the thicker row focus indicator */
488492
.spectrum-Table-cell:first-child {
489493
position: relative;
490-
overflow: hidden;
491-
outline: none;
494+
border-inline-start: 0;
495+
border-block: var(--spectrum-table-row-focus-indicator-outline-width) solid var(--highcontrast-table-focus-indicator-color, var(--mod-table-focus-indicator-color, var(--spectrum-table-focus-indicator-color)));
492496

497+
/* The side row focus indicator line */
493498
&::before {
494499
content: "";
495500
position: absolute;
@@ -502,6 +507,20 @@
502507
}
503508
}
504509

510+
/* All other cells in focused rows (including the first rows after the header row and last rows in the table) need the focus indicator border */
511+
&:first-child .spectrum-Table-cell,
512+
&:last-child .spectrum-Table-cell,
513+
.spectrum-Table-cell {
514+
border-block: var(--spectrum-table-row-focus-indicator-outline-width) solid var(--highcontrast-table-focus-indicator-color, var(--mod-table-focus-indicator-color, var(--spectrum-table-focus-indicator-color)));
515+
}
516+
517+
/* Last cell of focused row needs the fancy new focus indicator borders at the end */
518+
.spectrum-Table-cell:last-child {
519+
border-inline-end: var(--spectrum-table-row-focus-indicator-outline-width) solid var(--highcontrast-table-focus-indicator-color, var(--mod-table-focus-indicator-color, var(--spectrum-table-focus-indicator-color)));
520+
border-block-end: var(--spectrum-table-row-focus-indicator-outline-width) solid var(--highcontrast-table-focus-indicator-color, var(--mod-table-focus-indicator-color, var(--spectrum-table-focus-indicator-color)));
521+
}
522+
523+
/* In a focused row that is last in the table, the first cell needs rounded corners at the bottom of the row focus indicator line */
505524
&:last-child .spectrum-Table-cell:first-child::before {
506525
border-end-start-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius));
507526
}
@@ -843,6 +862,11 @@
843862
.spectrum-Table-cell:first-child::before {
844863
background-color: Highlight;
845864
}
865+
866+
/* Make sure border colors are visible in high contrast mode */
867+
/* .spectrum-Table-cell {
868+
border-color: Highlight;
869+
} */
846870
}
847871
}
848872

0 commit comments

Comments
 (0)