Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): adjust bx--actions-list in data table to use display grid instead of position absolute #9994

Merged
merged 16 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
// Need for batch actions
position: relative;
display: flex;
overflow: hidden;
width: 100%;
height: $spacing-09;
min-height: $spacing-09;
background-color: $layer;
}

Expand Down Expand Up @@ -320,17 +319,14 @@
//-------------------------------------------------
.#{$prefix}--batch-actions {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
width: 100%;
height: 100%;
align-items: center;
padding-right: $spacing-06;
padding-left: $spacing-06;
justify-content: space-between;
background-color: $background-brand;
clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
overflow-x: auto;
pointer-events: none;
transform: translate3d(0, 48px, 0);
transition: transform $duration--fast-02 motion(standard, productive),
Expand All @@ -344,22 +340,22 @@
}

.#{$prefix}--batch-actions--active {
overflow: auto hidden;
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
pointer-events: all;
transform: translate3d(0, 0, 0);
}

//btns container
.#{$prefix}--action-list {
position: absolute;
right: 0;
display: flex;
align-items: center;
}

.#{$prefix}--action-list .#{$prefix}--btn {
min-width: 0;
padding: $button-padding-ghost;
color: $text-on-color;
white-space: nowrap;
}

.#{$prefix}--action-list .#{$prefix}--btn:disabled {
Expand Down Expand Up @@ -424,22 +420,24 @@
transition: opacity $transition--base $carbon--standard-easing;
}

// cancel btn
.#{$prefix}--batch-summary__cancel {
position: relative;
padding-right: $spacing-05;
}

// items selected text
.#{$prefix}--batch-summary {
position: absolute;
position: sticky;
z-index: 100000;
left: 0;
display: flex;
min-height: 3rem;
align-items: center;
margin-left: $spacing-05;
padding: 0 $spacing-05;
background-color: $background-brand;

color: $text-on-color;
}

.#{$prefix}--batch-summary__scroll {
box-shadow: 0.5px 0 0.2px $hover-primary-text;
}

.#{$prefix}--batch-summary__para {
@include type-style('body-short-01');
}
Expand Down
14 changes: 11 additions & 3 deletions packages/react/src/components/DataTable/TableBatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const TableBatchActions = ({
translateWithId: t,
...rest
}) => {
const [isScrolling, setIsScrolling] = React.useState();
const batchActionsClasses = cx(
{
[`${prefix}--batch-actions`]: true,
Expand All @@ -44,12 +45,19 @@ const TableBatchActions = ({
className
);

const batchSummaryClasses = cx(`${prefix}--batch-summary`, {
[`${prefix}--batch-summary__scroll`]: isScrolling,
});

return (
<div
{...rest}
onScroll={() => {
setIsScrolling(!isScrolling);
}}
aria-hidden={!shouldShowBatchActions}
className={batchActionsClasses}>
<div className={`${prefix}--batch-summary`}>
className={batchActionsClasses}
{...rest}>
<div className={batchSummaryClasses}>
<p className={`${prefix}--batch-summary__para`}>
<span>
{totalSelected > 1 || totalSelected === 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ exports[`DataTable should render 1`] = `
<div
aria-hidden={true}
className="bx--batch-actions"
onScroll={[Function]}
>
<div
className="bx--batch-summary"
Expand Down Expand Up @@ -3094,6 +3095,7 @@ exports[`DataTable sticky header should render 1`] = `
<div
aria-hidden={true}
className="bx--batch-actions"
onScroll={[Function]}
>
<div
className="bx--batch-summary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports[`DataTable.TableBatchActions should render 1`] = `
<div
aria-hidden={true}
className="bx--batch-actions custom-class"
onScroll={[Function]}
>
<div
className="bx--batch-summary"
Expand Down Expand Up @@ -73,6 +74,7 @@ exports[`DataTable.TableBatchActions should render 2`] = `
<div
aria-hidden={false}
className="bx--batch-actions bx--batch-actions--active custom-class"
onScroll={[Function]}
>
<div
className="bx--batch-summary"
Expand Down