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(DataTable): useStaticWidth fix for title/description #9632

Merged
merged 4 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -724,6 +724,10 @@
width: auto;
}

.#{$prefix}--data-table-container--static {
width: fit-content;
}

// -------------
// Sticky header
// -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,9 @@ Map {
"title": Object {
"type": "node",
},
"useStaticWidth": Object {
"type": "bool",
},
},
},
"TableExpandHeader": Object {
Expand Down Expand Up @@ -1771,6 +1774,9 @@ Map {
"title": Object {
"type": "node",
},
"useStaticWidth": Object {
"type": "bool",
},
},
},
"TableExpandHeader" => Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const props = () => ({
'lg'
),
stickyHeader: boolean('Sticky header (experimental)', false),
useStaticWidth: boolean('Use static width (useStaticWidth)', false),
});

export default {
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/DataTable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,11 @@ export default class DataTable extends React.Component {
* Helper utility to get the TableContainer Props.
*/
getTableContainerProps = () => {
const { stickyHeader } = this.props;
const { stickyHeader, useStaticWidth } = this.props;

return {
stickyHeader,
useStaticWidth,
};
};

Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/components/DataTable/TableContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ const TableContainer = ({
title,
description,
stickyHeader,
useStaticWidth,
...rest
}) => {
const tableContainerClasses = cx(
className,
`${prefix}--data-table-container`,
{
[`${prefix}--data-table--max-width`]: stickyHeader,
[`${prefix}--data-table-container--static`]: useStaticWidth,
}
);

Expand Down Expand Up @@ -60,6 +62,11 @@ TableContainer.propTypes = {
* Provide a title for the Table
*/
title: PropTypes.node,

/**
* If true, will use a width of 'fit-content' to match the inner table width
*/
useStaticWidth: PropTypes.bool,
};

export default TableContainer;