Skip to content

Commit 3e6bb52

Browse files
committed
simplify borders, improve focus ring
1 parent 01ba1a6 commit 3e6bb52

1 file changed

Lines changed: 33 additions & 22 deletions

File tree

packages/@react-spectrum/s2/src/TableView.tsx

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,15 @@ function CellFocusRing() {
688688
return (
689689
<div
690690
role="presentation"
691-
className={style({...cellFocus, position: 'absolute', inset: 0, pointerEvents: 'none'})({
691+
className={style({
692+
...cellFocus,
693+
position: 'absolute',
694+
top: 'var(--topFocusRing)',
695+
bottom: 0,
696+
insetStart: 0,
697+
insetEnd: 0,
698+
pointerEvents: 'none'
699+
})({
692700
isFocusVisible: true
693701
})}
694702
/>
@@ -2022,24 +2030,16 @@ const row = style<
20222030
}
20232031
},
20242032
borderTopWidth: 0,
2025-
borderBottomWidth: {
2026-
selectionStyle: {
2027-
highlight: {
2028-
default: 1,
2029-
isSelected: 0,
2030-
isNextSelected: 0
2031-
},
2032-
checkbox: 1
2033-
}
2034-
},
2033+
borderBottomWidth: 1,
20352034
borderStartWidth: 0,
20362035
borderEndWidth: 0,
20372036
borderStyle: 'solid',
20382037
borderColor: {
20392038
selectionStyle: {
20402039
highlight: {
20412040
default: 'gray-300',
2042-
isSelected: 'transparent'
2041+
isSelected: 'transparent',
2042+
isNextSelected: 'transparent'
20432043
},
20442044
checkbox: 'gray-300'
20452045
}
@@ -2081,22 +2081,34 @@ const row = style<
20812081
},
20822082
isolation: 'isolate',
20832083
forcedColorAdjust: 'none',
2084-
'--topPosition': {
2084+
'--topFocusRing': {
20852085
type: 'top',
20862086
value: {
20872087
default: '[-1px]',
20882088
isFirstItem: 0
20892089
}
20902090
},
2091+
'--topHighlightBorder': {
2092+
type: 'top',
2093+
value: {
2094+
default: 0,
2095+
isSelected: '[-1px]',
2096+
// Don't overlap focus ring of row above.
2097+
isPrevSelected: 0,
2098+
isFirstItem: 0,
2099+
forcedColors: 0
2100+
}
2101+
},
20912102
'--bottomPosition': {
20922103
type: 'bottom',
20932104
value: {
2094-
default: '[-1px]',
20952105
selectionStyle: {
2096-
highlight: {
2106+
checkbox: {
20972107
default: '[-1px]',
2098-
isSelected: 0
2099-
}
2108+
// Avoid the next row's selected background covering this row's focus ring.
2109+
isNextSelected: 0
2110+
},
2111+
highlight: '[-1px]'
21002112
}
21012113
}
21022114
}
@@ -2107,12 +2119,11 @@ const row = style<
21072119
const highlightSelectionBorder = css(
21082120
`&:before {
21092121
content: "";
2110-
width: 100%;
2111-
height: 100%;
2122+
top: var(--topHighlightBorder);
2123+
bottom: -1px;
2124+
inset-inline: 0;
21122125
position: absolute;
2113-
inset: 0;
21142126
z-index: 3;
2115-
box-sizing: border-box;
21162127
border-style: solid;
21172128
border-color: var(--borderColor);
21182129
border-top-width: var(--borderTopWidth);
@@ -2131,7 +2142,7 @@ const highlightSelectionBorder = css(
21312142
const focusIndicator = css(
21322143
`&:after {
21332144
content: "";
2134-
top: var(--topPosition);
2145+
top: var(--topFocusRing);
21352146
bottom: var(--bottomPosition);
21362147
z-index: 3;
21372148
inset-inline-start: 0;

0 commit comments

Comments
 (0)