Skip to content

Commit

Permalink
fix(table-batch-action): remove default iconDescription, add proptype…
Browse files Browse the repository at this point in the history
… check, update stories (#3928)
  • Loading branch information
jendowns authored and asudoh committed Sep 10, 2019
1 parent 4c06756 commit 765e7ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
18 changes: 15 additions & 3 deletions packages/react/src/components/DataTable/TableBatchAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,22 @@ const TableBatchAction = props => <Button {...props} />;

TableBatchAction.propTypes = {
/**
* Provide a text description for the icon in the button
* Specify if the button is an icon-only button
*/
iconDescription: PropTypes.string.isRequired,
hasIconOnly: PropTypes.bool,

/**
* If specifying the `renderIcon` prop, provide a description for that icon that can
* be read by screen readers
*/
iconDescription: props => {
if (props.renderIcon && !props.children && !props.iconDescription) {
return new Error(
'renderIcon property specified without also providing an iconDescription property.'
);
}
return undefined;
},

/**
* Optional function to render your own icon in the underlying button
Expand All @@ -25,7 +38,6 @@ TableBatchAction.propTypes = {
};

TableBatchAction.defaultProps = {
iconDescription: 'Add',
renderIcon: iconAddSolid,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,6 @@ exports[`DataTable should render 1`] = `
translateWithId={[Function]}
>
<TableBatchAction
iconDescription="Add"
onClick={[MockFunction]}
renderIcon={
Object {
Expand All @@ -1776,7 +1775,6 @@ exports[`DataTable should render 1`] = `
Ghost
</TableBatchAction>
<TableBatchAction
iconDescription="Add"
onClick={[MockFunction]}
renderIcon={
Object {
Expand All @@ -1788,7 +1786,6 @@ exports[`DataTable should render 1`] = `
Ghost
</TableBatchAction>
<TableBatchAction
iconDescription="Add"
onClick={[MockFunction]}
renderIcon={
Object {
Expand Down Expand Up @@ -1965,7 +1962,6 @@ exports[`DataTable should render 1`] = `
className="bx--action-list"
>
<TableBatchAction
iconDescription="Add"
onClick={[MockFunction]}
renderIcon={
Object {
Expand All @@ -1976,7 +1972,6 @@ exports[`DataTable should render 1`] = `
>
<ForwardRef(Button)
disabled={false}
iconDescription="Add"
kind="primary"
onClick={[MockFunction]}
renderIcon={
Expand All @@ -1998,12 +1993,10 @@ exports[`DataTable should render 1`] = `
Ghost
<ForwardRef(AddFilled16)
aria-hidden="true"
aria-label="Add"
className="bx--btn__icon"
>
<Icon
aria-hidden="true"
aria-label="Add"
className="bx--btn__icon"
height={16}
preserveAspectRatio="xMidYMid meet"
Expand All @@ -2012,13 +2005,11 @@ exports[`DataTable should render 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<svg
aria-hidden="true"
aria-label="Add"
aria-hidden={true}
className="bx--btn__icon"
focusable="false"
height={16}
preserveAspectRatio="xMidYMid meet"
role="img"
style={
Object {
"willChange": "transform",
Expand All @@ -2038,7 +2029,6 @@ exports[`DataTable should render 1`] = `
</ForwardRef(Button)>
</TableBatchAction>
<TableBatchAction
iconDescription="Add"
onClick={[MockFunction]}
renderIcon={
Object {
Expand All @@ -2049,7 +2039,6 @@ exports[`DataTable should render 1`] = `
>
<ForwardRef(Button)
disabled={false}
iconDescription="Add"
kind="primary"
onClick={[MockFunction]}
renderIcon={
Expand All @@ -2071,12 +2060,10 @@ exports[`DataTable should render 1`] = `
Ghost
<ForwardRef(AddFilled16)
aria-hidden="true"
aria-label="Add"
className="bx--btn__icon"
>
<Icon
aria-hidden="true"
aria-label="Add"
className="bx--btn__icon"
height={16}
preserveAspectRatio="xMidYMid meet"
Expand All @@ -2085,13 +2072,11 @@ exports[`DataTable should render 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<svg
aria-hidden="true"
aria-label="Add"
aria-hidden={true}
className="bx--btn__icon"
focusable="false"
height={16}
preserveAspectRatio="xMidYMid meet"
role="img"
style={
Object {
"willChange": "transform",
Expand All @@ -2111,7 +2096,6 @@ exports[`DataTable should render 1`] = `
</ForwardRef(Button)>
</TableBatchAction>
<TableBatchAction
iconDescription="Add"
onClick={[MockFunction]}
renderIcon={
Object {
Expand All @@ -2122,7 +2106,6 @@ exports[`DataTable should render 1`] = `
>
<ForwardRef(Button)
disabled={false}
iconDescription="Add"
kind="primary"
onClick={[MockFunction]}
renderIcon={
Expand All @@ -2144,12 +2127,10 @@ exports[`DataTable should render 1`] = `
Ghost
<ForwardRef(AddFilled16)
aria-hidden="true"
aria-label="Add"
className="bx--btn__icon"
>
<Icon
aria-hidden="true"
aria-label="Add"
className="bx--btn__icon"
height={16}
preserveAspectRatio="xMidYMid meet"
Expand All @@ -2158,13 +2139,11 @@ exports[`DataTable should render 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<svg
aria-hidden="true"
aria-label="Add"
aria-hidden={true}
className="bx--btn__icon"
focusable="false"
height={16}
preserveAspectRatio="xMidYMid meet"
role="img"
style={
Object {
"willChange": "transform",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
exports[`DataTable.TableBatchAction should render 1`] = `
<TableBatchAction
className="custom-class"
iconDescription="Add"
renderIcon={
Object {
"$$typeof": Symbol(react.forward_ref),
Expand All @@ -14,7 +13,6 @@ exports[`DataTable.TableBatchAction should render 1`] = `
<ForwardRef(Button)
className="custom-class"
disabled={false}
iconDescription="Add"
kind="primary"
renderIcon={
Object {
Expand All @@ -33,12 +31,10 @@ exports[`DataTable.TableBatchAction should render 1`] = `
>
<ForwardRef(AddFilled16)
aria-hidden="true"
aria-label="Add"
className="bx--btn__icon"
>
<Icon
aria-hidden="true"
aria-label="Add"
className="bx--btn__icon"
height={16}
preserveAspectRatio="xMidYMid meet"
Expand All @@ -47,13 +43,11 @@ exports[`DataTable.TableBatchAction should render 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<svg
aria-hidden="true"
aria-label="Add"
aria-hidden={true}
className="bx--btn__icon"
focusable="false"
height={16}
preserveAspectRatio="xMidYMid meet"
role="img"
style={
Object {
"willChange": "transform",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,16 @@ export default props => (
<TableBatchActions {...getBatchActionProps()}>
<TableBatchAction
renderIcon={Delete}
iconDescription="Delete the selected rows"
onClick={batchActionClick(selectedRows)}>
Delete
</TableBatchAction>
<TableBatchAction
renderIcon={Save}
iconDescription="Save the selected rows"
onClick={batchActionClick(selectedRows)}>
Save
</TableBatchAction>
<TableBatchAction
renderIcon={Download}
iconDescription="Download the selected rows"
onClick={batchActionClick(selectedRows)}>
Download
</TableBatchAction>
Expand Down

0 comments on commit 765e7ec

Please sign in to comment.