Skip to content

Commit d962f10

Browse files
authored
fix(data-table): increase interactive area of expand button (#7392)
* refactor: consolidate expandable button rules * refactor: remove duplicate style rules * fix(data-table): place header label indentation on container div * fix(data-table): restore custom checkbox padding rules * fix(data-table): increase interactive area of expand button * fix(data-table): affix row height
1 parent d41f538 commit d962f10

File tree

2 files changed

+52
-24
lines changed

2 files changed

+52
-24
lines changed

packages/components/src/components/data-table/_data-table-core.scss

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,9 @@
9898
vertical-align: middle;
9999
}
100100

101-
.#{$prefix}--data-table td {
101+
.#{$prefix}--data-table th {
102102
padding-right: $spacing-05;
103103
padding-left: $spacing-05;
104-
}
105-
106-
.#{$prefix}--data-table th {
107104
color: $text-01;
108105
background-color: $ui-03;
109106
}
@@ -115,8 +112,6 @@
115112
}
116113

117114
.#{$prefix}--data-table .#{$prefix}--table-header-label {
118-
padding-right: $spacing-05;
119-
padding-left: $spacing-05;
120115
text-align: left;
121116
}
122117

@@ -283,22 +278,40 @@
283278
.#{$prefix}--data-table thead th.#{$prefix}--table-expand,
284279
.#{$prefix}--data-table tbody td.#{$prefix}--table-expand {
285280
min-width: 0;
286-
// spacing between checkbox / chevron and next cell should be 16px / 1rem
287-
// adjacent cell has 16px / 1rem padding-left though, hence the removal of padding-right here
288-
padding-right: 0;
289-
padding-left: $spacing-05;
290281
}
291282

292283
.#{$prefix}--data-table thead th.#{$prefix}--table-column-checkbox,
293284
.#{$prefix}--data-table tbody td.#{$prefix}--table-column-checkbox {
294285
// 16px padding left + 20px checkbox width
295-
width: rem(36px);
286+
width: rem(16px);
287+
// spacing between checkbox / chevron and next cell should be 16px / 1rem
288+
// adjacent cell has 16px / 1rem padding-left though, hence the removal of padding-right here
289+
padding-right: $spacing-05;
290+
padding-left: $spacing-05;
296291
}
297292

298293
.#{$prefix}--data-table thead th.#{$prefix}--table-expand,
299294
.#{$prefix}--data-table tbody td.#{$prefix}--table-expand {
300-
// 16px padding left + 16px checkbox width
295+
width: rem(48px);
296+
height: rem(48px);
297+
}
298+
299+
.#{$prefix}--data-table--compact thead th.#{$prefix}--table-expand,
300+
.#{$prefix}--data-table--compact tbody td.#{$prefix}--table-expand {
301+
width: rem(24px);
302+
height: rem(24px);
303+
}
304+
305+
.#{$prefix}--data-table--short thead th.#{$prefix}--table-expand,
306+
.#{$prefix}--data-table--short tbody td.#{$prefix}--table-expand {
301307
width: rem(32px);
308+
height: rem(32px);
309+
}
310+
311+
.#{$prefix}--data-table--tall thead th.#{$prefix}--table-expand,
312+
.#{$prefix}--data-table--tall tbody td.#{$prefix}--table-expand {
313+
width: rem(64px);
314+
height: rem(64px);
302315
}
303316

304317
.#{$prefix}--data-table--tall .#{$prefix}--table-column-checkbox {

packages/components/src/components/data-table/_data-table-expandable.scss

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,26 @@
161161
// Expand icon column
162162
//----------------------------------------------------------------------------
163163
.#{$prefix}--data-table td.#{$prefix}--table-expand {
164-
width: 2.5rem;
165-
min-width: 2.5rem;
166164
border-bottom: 1px solid $ui-03;
167165
}
168166

169-
.#{$prefix}--data-table td.#{$prefix}--table-expand,
170-
th.#{$prefix}--table-expand {
171-
padding: 0 $spacing-05;
167+
.#{$prefix}--data-table th.#{$prefix}--table-expand + th,
168+
.#{$prefix}--data-table td.#{$prefix}--table-expand + td {
169+
padding-left: 0;
172170
}
173171

174-
.#{$prefix}--data-table--tall td.#{$prefix}--table-expand,
175-
.#{$prefix}--data-table--tall th.#{$prefix}--table-expand {
176-
padding-top: rem(16px);
177-
padding-bottom: rem(16px);
172+
.#{$prefix}--data-table
173+
th.#{$prefix}--table-expand
174+
+ .#{$prefix}--table-column-checkbox,
175+
.#{$prefix}--data-table
176+
td.#{$prefix}--table-expand
177+
+ .#{$prefix}--table-column-checkbox {
178+
padding-right: 0;
179+
}
180+
181+
.#{$prefix}--data-table td.#{$prefix}--table-expand,
182+
.#{$prefix}--data-table th.#{$prefix}--table-expand {
183+
padding: 0;
178184
}
179185

180186
.#{$prefix}--data-table
@@ -191,17 +197,21 @@
191197
.#{$prefix}--table-expand__button {
192198
@include button-reset('false');
193199

194-
height: rem(16px);
200+
display: inline-flex;
201+
align-items: center;
202+
justify-content: center;
203+
width: 100%;
204+
// Account for the border in `.bx--table-expand`
205+
height: calc(100% + 1px);
195206
vertical-align: inherit;
196207
}
197208

198209
.#{$prefix}--table-expand__button:focus {
199210
outline: none;
211+
box-shadow: inset 0 0 0 2px $focus;
200212
}
201213

202214
.#{$prefix}--table-expand__button:focus .#{$prefix}--table-expand__svg {
203-
box-shadow: inset 0 0 0 2px $focus;
204-
205215
// Windows, Firefox HCM Fix
206216
@media screen and (-ms-high-contrast: active),
207217
screen and (prefers-contrast) {
@@ -222,6 +232,11 @@
222232
}
223233
}
224234

235+
.#{$prefix}--data-table--tall .#{$prefix}--table-expand__button {
236+
padding-top: rem(16px);
237+
padding-bottom: rem(24px);
238+
}
239+
225240
// fix expanded parent separating border length
226241
tr.#{$prefix}--parent-row.#{$prefix}--expandable-row
227242
td.#{$prefix}--table-expand

0 commit comments

Comments
 (0)