Skip to content

Commit 98d99cb

Browse files
authored
fix(TableView): updated disabled behavior to match ListView/TreeView (adobe#9720)
* fix(TableView): hide row selection checkbox if disabled (for all disabledBehaviors). * use disabled text color for disabledBehavior="all"
1 parent cf84735 commit 98d99cb

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

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

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -947,21 +947,13 @@ const commonCellStyles = {
947947
borderXWidth: 0,
948948
borderStyle: 'solid',
949949
position: 'relative',
950-
color: {
951-
default: 'gray-800',
952-
forcedColors: 'ButtonText'
953-
},
950+
color: '--rowTextColor',
954951
outlineStyle: 'none',
955952
paddingX: 16 // table-edge-to-content
956953
} as const;
957954

958955
const cell = style<CellRenderProps & S2TableProps & {isDivider: boolean}>({
959956
...commonCellStyles,
960-
color: {
961-
default: baseColor('neutral-subdued'),
962-
isSelected: baseColor('neutral'),
963-
forcedColors: 'ButtonText'
964-
},
965957
paddingY: centerPadding(),
966958
minHeight: {
967959
default: 40,
@@ -1398,6 +1390,16 @@ const rowBackgroundColor = {
13981390
}
13991391
} as const;
14001392

1393+
const rowTextColor = {
1394+
default: baseColor('neutral-subdued'),
1395+
isSelected: baseColor('neutral'),
1396+
isDisabled: {
1397+
default: 'disabled',
1398+
forcedColors: 'GrayText'
1399+
},
1400+
forcedColors: 'ButtonText'
1401+
} as const;
1402+
14011403
const row = style<RowRenderProps & S2TableProps>({
14021404
height: 'full',
14031405
position: 'relative',
@@ -1407,6 +1409,10 @@ const row = style<RowRenderProps & S2TableProps>({
14071409
type: 'backgroundColor',
14081410
value: rowBackgroundColor
14091411
},
1412+
'--rowTextColor': {
1413+
type: 'color',
1414+
value: rowTextColor
1415+
},
14101416
'--rowFocusIndicatorColor': {
14111417
type: 'outlineColor',
14121418
value: {
@@ -1451,6 +1457,13 @@ const row = style<RowRenderProps & S2TableProps>({
14511457
forcedColorAdjust: 'none'
14521458
});
14531459

1460+
const selectionCheckbox = style({
1461+
visibility: {
1462+
default: 'visible',
1463+
':is([slot="selection"][data-disabled="true"])': 'hidden'
1464+
}
1465+
});
1466+
14541467
export interface RowProps<T> extends Pick<RACRowProps<T>, 'id' | 'columns' | 'isDisabled' | 'onAction' | 'children' | 'textValue' | 'dependencies' | keyof GlobalDOMAttributes>, LinkDOMProps {}
14551468

14561469
/**
@@ -1477,7 +1490,7 @@ export const Row = /*#__PURE__*/ (forwardRef as forwardRefType)(function Row<T e
14771490
// The `spread` otherProps must be after className in Cell.
14781491
// @ts-ignore
14791492
<Cell isSticky className={checkboxCellStyle}>
1480-
<Checkbox slot="selection" />
1493+
<Checkbox slot="selection" styles={selectionCheckbox} />
14811494
</Cell>
14821495
)}
14831496
<Collection items={columns} dependencies={[...dependencies, columns]}>

0 commit comments

Comments
 (0)