Skip to content

Commit 2126a08

Browse files
authored
#2089 cleaning up selected checkbox whitespace (#2145)
1 parent 69850d8 commit 2126a08

File tree

3 files changed

+56
-23
lines changed

3 files changed

+56
-23
lines changed

packages/@adobe/spectrum-css-temp/components/table/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ governing permissions and limitations under the License.
284284
padding-top: 0px;
285285
padding-bottom: 0px;
286286
vertical-align: var(--spectrum-table-cell-checkbox-vertical-alignment);
287+
288+
.spectrum-Table-checkbox {
289+
padding-inline-end: 0px;
290+
}
287291
}
288292

289293
.spectrum-Table-checkbox {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ const ROW_HEIGHTS = {
6161
}
6262
};
6363

64-
const SELECTION_CELL_DEFAULT_WIDTH = 55;
64+
const SELECTION_CELL_DEFAULT_WIDTH = {
65+
medium: 38,
66+
large: 48
67+
};
6568

6669
const TableContext = React.createContext<TableState<unknown>>(null);
6770
function useTableContext() {
@@ -97,7 +100,7 @@ function TableView<T extends object>(props: SpectrumTableProps<T>, ref: DOMRef<H
97100
let width = DEFAULT_HIDE_HEADER_CELL_WIDTH[scale];
98101
return showDivider ? width + 1 : width;
99102
} else if (isSelectionCell) {
100-
return SELECTION_CELL_DEFAULT_WIDTH;
103+
return SELECTION_CELL_DEFAULT_WIDTH[scale];
101104
}
102105
}
103106
}), [props.overflowMode, scale, density]);

packages/@react-spectrum/table/test/Table.test.js

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,10 +3550,36 @@ describe('TableView', function () {
35503550
let rows = tree.getAllByRole('row');
35513551

35523552
for (let row of rows) {
3553-
expect(row.childNodes[0].style.width).toBe('55px');
3554-
expect(row.childNodes[1].style.width).toBe('315px');
3555-
expect(row.childNodes[2].style.width).toBe('315px');
3556-
expect(row.childNodes[3].style.width).toBe('315px');
3553+
expect(row.childNodes[0].style.width).toBe('38px');
3554+
expect(row.childNodes[1].style.width).toBe('320.6666666666667px');
3555+
expect(row.childNodes[2].style.width).toBe('320.6666666666667px');
3556+
expect(row.childNodes[3].style.width).toBe('320.6666666666667px');
3557+
}
3558+
});
3559+
3560+
it('should divide the available width by default in large scale', function () {
3561+
let tree = render((
3562+
<TableView aria-label="Table" selectionMode="multiple">
3563+
<TableHeader columns={columns}>
3564+
{column => <Column>{column.name}</Column>}
3565+
</TableHeader>
3566+
<TableBody items={items}>
3567+
{item =>
3568+
(<Row key={item.foo}>
3569+
{key => <Cell>{item[key]}</Cell>}
3570+
</Row>)
3571+
}
3572+
</TableBody>
3573+
</TableView>
3574+
), 'large');
3575+
3576+
let rows = tree.getAllByRole('row');
3577+
3578+
for (let row of rows) {
3579+
expect(row.childNodes[0].style.width).toBe('48px');
3580+
expect(row.childNodes[1].style.width).toBe('317.3333333333333px');
3581+
expect(row.childNodes[2].style.width).toBe('317.3333333333333px');
3582+
expect(row.childNodes[3].style.width).toBe('317.3333333333333px');
35573583
}
35583584
});
35593585

@@ -3605,10 +3631,10 @@ describe('TableView', function () {
36053631
let rows = tree.getAllByRole('row');
36063632

36073633
for (let row of rows) {
3608-
expect(row.childNodes[0].style.width).toBe('55px');
3634+
expect(row.childNodes[0].style.width).toBe('38px');
36093635
expect(row.childNodes[1].style.width).toBe('200px');
3610-
expect(row.childNodes[2].style.width).toBe('372.5px');
3611-
expect(row.childNodes[3].style.width).toBe('372.5px');
3636+
expect(row.childNodes[2].style.width).toBe('381px');
3637+
expect(row.childNodes[3].style.width).toBe('381px');
36123638
}
36133639
});
36143640

@@ -3660,10 +3686,10 @@ describe('TableView', function () {
36603686
let rows = tree.getAllByRole('row');
36613687

36623688
for (let row of rows) {
3663-
expect(row.childNodes[0].style.width).toBe('55px');
3689+
expect(row.childNodes[0].style.width).toBe('38px');
36643690
expect(row.childNodes[1].style.width).toBe('200px');
36653691
expect(row.childNodes[2].style.width).toBe('500px');
3666-
expect(row.childNodes[3].style.width).toBe('245px');
3692+
expect(row.childNodes[3].style.width).toBe('262px');
36673693
}
36683694
});
36693695

@@ -3713,21 +3739,21 @@ describe('TableView', function () {
37133739

37143740
let rows = tree.getAllByRole('row');
37153741

3716-
expect(rows[0].childNodes[0].style.width).toBe('244px');
3717-
expect(rows[0].childNodes[1].style.width).toBe('756px');
3742+
expect(rows[0].childNodes[0].style.width).toBe('230.4px');
3743+
expect(rows[0].childNodes[1].style.width).toBe('769.6px');
37183744

3719-
expect(rows[1].childNodes[0].style.width).toBe('244px');
3720-
expect(rows[1].childNodes[1].style.width).toBe('378px');
3721-
expect(rows[1].childNodes[2].style.width).toBe('189px');
3722-
expect(rows[1].childNodes[3].style.width).toBe('189px');
3745+
expect(rows[1].childNodes[0].style.width).toBe('230.4px');
3746+
expect(rows[1].childNodes[1].style.width).toBe('384.8px');
3747+
expect(rows[1].childNodes[2].style.width).toBe('192.4px');
3748+
expect(rows[1].childNodes[3].style.width).toBe('192.4px');
37233749

37243750
for (let row of rows.slice(2)) {
3725-
expect(row.childNodes[0].style.width).toBe('55px');
3726-
expect(row.childNodes[1].style.width).toBe('189px');
3727-
expect(row.childNodes[2].style.width).toBe('189px');
3728-
expect(row.childNodes[3].style.width).toBe('189px');
3729-
expect(row.childNodes[4].style.width).toBe('189px');
3730-
expect(row.childNodes[5].style.width).toBe('189px');
3751+
expect(row.childNodes[0].style.width).toBe('38px');
3752+
expect(row.childNodes[1].style.width).toBe('192.4px');
3753+
expect(row.childNodes[2].style.width).toBe('192.4px');
3754+
expect(row.childNodes[3].style.width).toBe('192.4px');
3755+
expect(row.childNodes[4].style.width).toBe('192.4px');
3756+
expect(row.childNodes[5].style.width).toBe('192.4px');
37313757
}
37323758
});
37333759
});

0 commit comments

Comments
 (0)