Skip to content

Commit

Permalink
fix(data-table): require additional props in certain situations (#5682)
Browse files Browse the repository at this point in the history
* fix(data-table): require additional props in certain situations

* fix(data-table): update snapshots

* fix(data-table): fix proptype

* fix(data-table): refactor to use exisiting func

Co-authored-by: Josh Black <[email protected]>
  • Loading branch information
2 people authored and Alessandra Davila committed Mar 25, 2020
1 parent 854c1b2 commit c095b57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
30 changes: 6 additions & 24 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -868,10 +868,7 @@ Map {
},
"TableExpandHeader": Object {
"propTypes": Object {
"ariaLabel": Object {
"isRequired": true,
"type": "string",
},
"ariaLabel": [Function],
"children": Object {
"type": "node",
},
Expand All @@ -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 {
Expand Down Expand Up @@ -1432,10 +1423,7 @@ Map {
},
"TableExpandHeader" => Object {
"propTypes": Object {
"ariaLabel": Object {
"isRequired": true,
"type": "string",
},
"ariaLabel": [Function],
"children": Object {
"type": "node",
},
Expand All @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions packages/react/src/components/DataTable/TableExpandHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 `<title>` element.
Expand Down

0 comments on commit c095b57

Please sign in to comment.