Skip to content

Commit f3422c4

Browse files
authored
feat(DataTable): allow additional contents to expand cells (#5060)
This change adds `children` prop support to `<TableExpandHeader>`. This provides applications with more control so application can better describe the expand cell. Fixes #5028.
1 parent e97a7ed commit f3422c4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

+30
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import cx from 'classnames';
9+
import PropTypes from 'prop-types';
910
import React from 'react';
1011
import { ChevronRight16 } from '@carbon/icons-react';
1112
import { settings } from 'carbon-components';
@@ -19,6 +20,7 @@ const TableExpandHeader = ({
1920
isExpanded,
2021
onExpand,
2122
expandIconDescription,
23+
children,
2224
...rest
2325
}) => {
2426
const className = cx(`${prefix}--table-expand`, headerClassName);
@@ -42,8 +44,36 @@ const TableExpandHeader = ({
4244
/>
4345
</button>
4446
)}
47+
{children}
4548
</th>
4649
);
4750
};
4851

52+
TableExpandHeader.propTypes = {
53+
className: PropTypes.string,
54+
children: PropTypes.node,
55+
56+
/**
57+
* Specify the string read by a voice reader when the expand trigger is
58+
* focused
59+
*/
60+
ariaLabel: PropTypes.string.isRequired,
61+
62+
/**
63+
* Specify whether this row is expanded or not. This helps coordinate data
64+
* attributes so that `TableExpandRow` and `TableExapndedRow` work together
65+
*/
66+
isExpanded: PropTypes.bool.isRequired,
67+
68+
/**
69+
* Hook for when a listener initiates a request to expand the given row
70+
*/
71+
onExpand: PropTypes.func.isRequired,
72+
73+
/**
74+
* The description of the chevron right icon, to be put in its SVG `<title>` element.
75+
*/
76+
expandIconDescription: PropTypes.string,
77+
};
78+
4979
export default TableExpandHeader;

0 commit comments

Comments
 (0)