Skip to content

Commit 963eb58

Browse files
authored
fix(react): adjust bx--actions-list in data table to use display grid instead of position absolute (#9994)
* fix(react): add display grid to actions list so scroll works * fix(react): remove commented out styles * fix(react): add more items to stroy and add back removed style * fix(react): adjust positioning so item summary is always visible * fix(react): update snapshots * fix(react): set min height on summary to match buttons * fix(react): remove test story
1 parent 4f39c2c commit 963eb58

4 files changed

Lines changed: 32 additions & 22 deletions

File tree

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
// Need for batch actions
2121
position: relative;
2222
display: flex;
23-
overflow: hidden;
2423
width: 100%;
25-
height: $spacing-09;
24+
min-height: $spacing-09;
2625
background-color: $layer;
2726
}
2827

@@ -320,17 +319,14 @@
320319
//-------------------------------------------------
321320
.#{$prefix}--batch-actions {
322321
position: absolute;
323-
top: 0;
322+
right: 0;
323+
bottom: 0;
324324
left: 0;
325325
display: flex;
326-
width: 100%;
327-
height: 100%;
328326
align-items: center;
329-
padding-right: $spacing-06;
330-
padding-left: $spacing-06;
327+
justify-content: space-between;
331328
background-color: $background-brand;
332329
clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
333-
overflow-x: auto;
334330
pointer-events: none;
335331
transform: translate3d(0, 48px, 0);
336332
transition: transform $duration--fast-02 motion(standard, productive),
@@ -344,22 +340,22 @@
344340
}
345341

346342
.#{$prefix}--batch-actions--active {
343+
overflow: auto hidden;
347344
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
348345
pointer-events: all;
349346
transform: translate3d(0, 0, 0);
350347
}
351348

352349
//btns container
353350
.#{$prefix}--action-list {
354-
position: absolute;
355-
right: 0;
356351
display: flex;
352+
align-items: center;
357353
}
358354

359355
.#{$prefix}--action-list .#{$prefix}--btn {
360-
min-width: 0;
361356
padding: $button-padding-ghost;
362357
color: $text-on-color;
358+
white-space: nowrap;
363359
}
364360

365361
.#{$prefix}--action-list .#{$prefix}--btn:disabled {
@@ -424,22 +420,24 @@
424420
transition: opacity $transition--base $carbon--standard-easing;
425421
}
426422

427-
// cancel btn
428-
.#{$prefix}--batch-summary__cancel {
429-
position: relative;
430-
padding-right: $spacing-05;
431-
}
432-
433423
// items selected text
434424
.#{$prefix}--batch-summary {
435-
position: absolute;
425+
position: sticky;
426+
z-index: 100000;
436427
left: 0;
437428
display: flex;
429+
min-height: 3rem;
438430
align-items: center;
439-
margin-left: $spacing-05;
431+
padding: 0 $spacing-05;
432+
background-color: $background-brand;
433+
440434
color: $text-on-color;
441435
}
442436

437+
.#{$prefix}--batch-summary__scroll {
438+
box-shadow: 0.5px 0 0.2px $hover-primary-text;
439+
}
440+
443441
.#{$prefix}--batch-summary__para {
444442
@include type-style('body-short-01');
445443
}

packages/react/src/components/DataTable/TableBatchActions.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const TableBatchActions = ({
3636
translateWithId: t,
3737
...rest
3838
}) => {
39+
const [isScrolling, setIsScrolling] = React.useState();
3940
const batchActionsClasses = cx(
4041
{
4142
[`${prefix}--batch-actions`]: true,
@@ -44,12 +45,19 @@ const TableBatchActions = ({
4445
className
4546
);
4647

48+
const batchSummaryClasses = cx(`${prefix}--batch-summary`, {
49+
[`${prefix}--batch-summary__scroll`]: isScrolling,
50+
});
51+
4752
return (
4853
<div
49-
{...rest}
54+
onScroll={() => {
55+
setIsScrolling(!isScrolling);
56+
}}
5057
aria-hidden={!shouldShowBatchActions}
51-
className={batchActionsClasses}>
52-
<div className={`${prefix}--batch-summary`}>
58+
className={batchActionsClasses}
59+
{...rest}>
60+
<div className={batchSummaryClasses}>
5361
<p className={`${prefix}--batch-summary__para`}>
5462
<span>
5563
{totalSelected > 1 || totalSelected === 0

packages/react/src/components/DataTable/__tests__/__snapshots__/DataTable-test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,6 +2036,7 @@ exports[`DataTable should render 1`] = `
20362036
<div
20372037
aria-hidden={true}
20382038
className="bx--batch-actions"
2039+
onScroll={[Function]}
20392040
>
20402041
<div
20412042
className="bx--batch-summary"
@@ -3094,6 +3095,7 @@ exports[`DataTable sticky header should render 1`] = `
30943095
<div
30953096
aria-hidden={true}
30963097
className="bx--batch-actions"
3098+
onScroll={[Function]}
30973099
>
30983100
<div
30993101
className="bx--batch-summary"

packages/react/src/components/DataTable/__tests__/__snapshots__/TableBatchActions-test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports[`DataTable.TableBatchActions should render 1`] = `
1111
<div
1212
aria-hidden={true}
1313
className="bx--batch-actions custom-class"
14+
onScroll={[Function]}
1415
>
1516
<div
1617
className="bx--batch-summary"
@@ -73,6 +74,7 @@ exports[`DataTable.TableBatchActions should render 2`] = `
7374
<div
7475
aria-hidden={false}
7576
className="bx--batch-actions bx--batch-actions--active custom-class"
77+
onScroll={[Function]}
7678
>
7779
<div
7880
className="bx--batch-summary"

0 commit comments

Comments
 (0)