Skip to content

Commit 08d5ee8

Browse files
authored
TableView DnD: improve css specificity (#4483)
1 parent 1b31109 commit 08d5ee8

File tree

2 files changed

+51
-39
lines changed

2 files changed

+51
-39
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ function TableVirtualizer({layout, collection, focusedKey, renderView, renderWra
726726
},
727727
classNames(
728728
stylesOverrides,
729+
'react-spectrum-Table-body',
729730
{
730731
'react-spectrum-Table-body--dropTarget': !!isRootDropTarget
731732
}
@@ -1124,7 +1125,8 @@ function TableDragHeaderCell({column}) {
11241125
'spectrum-Table-headCell',
11251126
classNames(
11261127
stylesOverrides,
1127-
'react-spectrum-dragButtonHeadCell'
1128+
'react-spectrum-Table-headCell',
1129+
'react-spectrum-Table-dragButtonHeadCell'
11281130
)
11291131
)
11301132
}>
@@ -1154,7 +1156,7 @@ function DragButton() {
11541156
className={
11551157
classNames(
11561158
stylesOverrides,
1157-
'spectrum-Table-row-draghandle-button'
1159+
'react-spectrum-Table-dragButton'
11581160
)
11591161
}
11601162
style={!isFocusVisibleWithin ? {...visuallyHiddenProps.style} : {}}
@@ -1290,6 +1292,7 @@ function TableRow({item, children, hasActions, isTableDraggable, isTableDroppabl
12901292
},
12911293
classNames(
12921294
stylesOverrides,
1295+
'react-spectrum-Table-row',
12931296
{'react-spectrum-Table-row--dropTarget': isDropTarget}
12941297
)
12951298
)

packages/@react-spectrum/table/src/table.css

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,15 @@
118118
}
119119
}
120120

121-
.react-spectrum-Table-body--dropTarget {
122-
border-color: var(--spectrum-table-dropindicator-border-color);
123-
background-color: var(--spectrum-alias-highlight-selected);
124-
box-shadow: inset 0 0 0 1px var(--spectrum-table-cell-border-color-key-focus);
121+
.react-spectrum-Table-body {
122+
&.react-spectrum-Table-body--dropTarget {
123+
border-color: var(--spectrum-table-dropindicator-border-color);
124+
background-color: var(--spectrum-alias-highlight-selected);
125+
box-shadow: inset 0 0 0 1px var(--spectrum-table-cell-border-color-key-focus);
125126

126-
/* forced-color-adjust: none, so that box-shadow style will render */
127-
forced-color-adjust: none;
127+
/* forced-color-adjust: none, so that box-shadow style will render */
128+
forced-color-adjust: none;
129+
}
128130
}
129131

130132
.react-spectrum-Table-InsertionIndicator {
@@ -170,46 +172,53 @@
170172
}
171173
}
172174

173-
.react-spectrum-Table-dragButtonCell {
174-
padding: var(--spectrum-global-dimension-size-40);
175+
.react-spectrum-Table-headCell {
176+
&.react-spectrum-Table-dragButtonHeadCell {
177+
padding: 0;
178+
height: inherit;
179+
}
175180
}
176181

177-
.spectrum-Table-row-draghandle-button {
178-
border-radius: var(--spectrum-alias-border-radius-regular);
179-
padding: var(--spectrum-global-dimension-size-10);
182+
.react-spectrum-Table-cell {
183+
&.react-spectrum-Table-dragButtonCell {
184+
padding: var(--spectrum-global-dimension-size-40);
180185

181-
&:focus-ring {
182-
box-shadow: inset 0 0 0 2px var(--spectrum-table-cell-border-color-key-focus);
183-
outline: none;
186+
.react-spectrum-Table-dragButton {
187+
border-radius: var(--spectrum-alias-border-radius-regular);
188+
padding: var(--spectrum-global-dimension-size-10);
184189

185-
/* forced-color-adjust: none, so that box-shadow style will render */
186-
forced-color-adjust: none;
187-
}
188-
svg {
189-
margin: auto 0;
190-
display: block;
191-
padding: var(--spectrum-global-dimension-size-40);
192-
}
193-
}
190+
&:focus-ring {
191+
box-shadow: inset 0 0 0 2px var(--spectrum-table-cell-border-color-key-focus);
192+
outline: none;
194193

195-
.react-spectrum-dragButtonHeadCell {
196-
padding: 0;
197-
height: inherit;
194+
/* forced-color-adjust: none, so that box-shadow style will render */
195+
forced-color-adjust: none;
196+
}
197+
198+
svg {
199+
margin: auto 0;
200+
display: block;
201+
padding: var(--spectrum-global-dimension-size-40);
202+
}
203+
}
204+
}
198205
}
199206

200-
.react-spectrum-Table-row--dropTarget {
201-
border: 1px var(--spectrum-table-dropindicator-border-color);
202-
box-shadow: inset 2px 0 0 0 var(--spectrum-table-dropindicator-border-color),
203-
inset -2px 0 0 0 var(--spectrum-table-dropindicator-border-color),
204-
inset 0 -3px 0 0 var(--spectrum-table-dropindicator-border-color),
205-
inset 0 2px 0 0 var(--spectrum-table-dropindicator-border-color);
207+
.react-spectrum-Table-row {
208+
&.react-spectrum-Table-row--dropTarget {
209+
border: 1px var(--spectrum-table-dropindicator-border-color);
210+
box-shadow: inset 2px 0 0 0 var(--spectrum-table-dropindicator-border-color),
211+
inset -2px 0 0 0 var(--spectrum-table-dropindicator-border-color),
212+
inset 0 -3px 0 0 var(--spectrum-table-dropindicator-border-color),
213+
inset 0 2px 0 0 var(--spectrum-table-dropindicator-border-color);
206214

207-
/* forced-color-adjust: none, so that box-shadow style will render */
208-
forced-color-adjust: none;
209-
}
215+
/* forced-color-adjust: none, so that box-shadow style will render */
216+
forced-color-adjust: none;
217+
}
210218

211-
.react-spectrum-Table-cellWrapper.react-spectrum-Table-cellWrapper--dropTarget {
212-
background-color: var(--spectrum-table-droptarget-background-color);
219+
.react-spectrum-Table-cellWrapper.react-spectrum-Table-cellWrapper--dropTarget {
220+
background-color: var(--spectrum-table-droptarget-background-color);
221+
}
213222
}
214223

215224
@media (forced-colors: active) {

0 commit comments

Comments
 (0)