diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index dd413f0a77f6..8cc5a3837a03 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -868,10 +868,7 @@ Map { }, "TableExpandHeader": Object { "propTypes": Object { - "ariaLabel": Object { - "isRequired": true, - "type": "string", - }, + "ariaLabel": [Function], "children": Object { "type": "node", }, @@ -881,14 +878,8 @@ Map { "expandIconDescription": Object { "type": "string", }, - "isExpanded": Object { - "isRequired": true, - "type": "bool", - }, - "onExpand": Object { - "isRequired": true, - "type": "func", - }, + "isExpanded": [Function], + "onExpand": [Function], }, }, "TableExpandRow": Object { @@ -1432,10 +1423,7 @@ Map { }, "TableExpandHeader" => Object { "propTypes": Object { - "ariaLabel": Object { - "isRequired": true, - "type": "string", - }, + "ariaLabel": [Function], "children": Object { "type": "node", }, @@ -1445,14 +1433,8 @@ Map { "expandIconDescription": Object { "type": "string", }, - "isExpanded": Object { - "isRequired": true, - "type": "bool", - }, - "onExpand": Object { - "isRequired": true, - "type": "func", - }, + "isExpanded": [Function], + "onExpand": [Function], }, }, "TableExpandRow" => Object { diff --git a/packages/react/src/components/DataTable/TableExpandHeader.js b/packages/react/src/components/DataTable/TableExpandHeader.js index e8228cd6e288..482682e8078a 100644 --- a/packages/react/src/components/DataTable/TableExpandHeader.js +++ b/packages/react/src/components/DataTable/TableExpandHeader.js @@ -7,6 +7,7 @@ import cx from 'classnames'; import PropTypes from 'prop-types'; +import requiredIfGivenPropExists from '../../prop-types/requiredIfGivenPropExists'; import React from 'react'; import { ChevronRight16 } from '@carbon/icons-react'; import { settings } from 'carbon-components'; @@ -57,18 +58,18 @@ TableExpandHeader.propTypes = { * Specify the string read by a voice reader when the expand trigger is * focused */ - ariaLabel: PropTypes.string.isRequired, + ariaLabel: requiredIfGivenPropExists('enableExpando', PropTypes.string), /** * Specify whether this row is expanded or not. This helps coordinate data * attributes so that `TableExpandRow` and `TableExapndedRow` work together */ - isExpanded: PropTypes.bool.isRequired, + isExpanded: requiredIfGivenPropExists('enableExpando', PropTypes.bool), /** * Hook for when a listener initiates a request to expand the given row */ - onExpand: PropTypes.func.isRequired, + onExpand: requiredIfGivenPropExists('enableExpando', PropTypes.func), /** * The description of the chevron right icon, to be put in its SVG `