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

feat(data-table): add colSpan prop for TableHeader #5088

Merged
Merged
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
16 changes: 12 additions & 4 deletions packages/react/src/components/DataTable/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const TableHeader = React.forwardRef(function TableHeader(
{
className: headerClassName,
children,
colSpan,
isSortable,
isSortHeader,
onClick,
Expand All @@ -63,7 +64,7 @@ const TableHeader = React.forwardRef(function TableHeader(
) {
if (!isSortable) {
return (
<th {...rest} className={headerClassName} scope={scope}>
<th {...rest} className={headerClassName} scope={scope} colSpan={colSpan}>
<span className={`${prefix}--table-header-label`}>{children}</span>
</th>
);
Expand All @@ -80,10 +81,11 @@ const TableHeader = React.forwardRef(function TableHeader(

return (
<th
scope={scope}
className={headerClassName}
aria-sort={ariaSort}
ref={ref}>
className={headerClassName}
colSpan={colSpan}
ref={ref}
scope={scope}>
<button className={className} onClick={onClick} {...rest}>
<span className={`${prefix}--table-header-label`}>{children}</span>
<Arrow
Expand Down Expand Up @@ -120,6 +122,12 @@ TableHeader.propTypes = {
*/
children: PropTypes.node,

/**
* Specify `colSpan` as a non-negative integer value to indicate how
* many columns the TableHeader cell extends in a table
*/
colSpan: PropTypes.number,

/**
* Specify whether this header is one through which a user can sort the table
*/
Expand Down