Skip to content

Commit

Permalink
fix(tableEmpty): sw-1537 aria-label attribute format (RedHatInsights#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Sep 22, 2023
1 parent ec7c9dd commit dfb0460
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5748,6 +5748,8 @@ Render an empty table.
<tr>
<td>props</td><td><code>object</code></td>
</tr><tr>
<td>props.ariaLabel</td><td><code>string</code></td>
</tr><tr>
<td>props.icon</td><td><code>React.ReactNode</code> | <code>function</code></td>
</tr><tr>
<td>props.message</td><td><code>React.ReactNode</code></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

exports[`TableEmpty Component should have fallback checks for certain props: fallback display 1`] = `
<EmptyTable>
<table />
<table
aria-label={null}
/>
<EmptyState
variant="small"
>
Expand All @@ -24,7 +26,9 @@ exports[`TableEmpty Component should have fallback checks for certain props: fal

exports[`TableEmpty Component should render a basic component: basic 1`] = `
<EmptyTable>
<table />
<table
aria-label={null}
/>
<EmptyState
variant="small"
>
Expand Down
11 changes: 7 additions & 4 deletions src/components/table/tableEmpty.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ import { EmptyTable as PlatformEmptyTableWrapper } from '@redhat-cloud-services/
* Render an empty table.
*
* @param {object} props
* @param {string} props.ariaLabel
* @param {React.ReactNode|Function} props.icon
* @param {React.ReactNode} props.message
* @param {string} props.tableHeading
* @param {React.ReactNode} props.title
* @param {string} props.variant
* @returns {React.ReactNode}
*/
const TableEmpty = ({ icon, message, tableHeading, title, variant, ...props }) => (
const TableEmpty = ({ ariaLabel, icon, message, tableHeading, title, variant, ...props }) => (
<PlatformEmptyTableWrapper>
<table {...props} />
<table aria-label={ariaLabel} {...props} />
<EmptyState variant={variant}>
{icon && <EmptyStateIcon icon={icon} />}
<Title headingLevel={tableHeading} size="lg">
Expand All @@ -37,9 +38,10 @@ const TableEmpty = ({ icon, message, tableHeading, title, variant, ...props }) =
* Prop types.
*
* @type {{icon: React.ReactNode|Function, variant: string, message: React.ReactNode, title: React.ReactNode,
* tableHeading: string}}
* tableHeading: string, ariaLabel: string}}
*/
TableEmpty.propTypes = {
ariaLabel: PropTypes.string,
icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
message: PropTypes.node.isRequired,
tableHeading: PropTypes.string,
Expand All @@ -50,9 +52,10 @@ TableEmpty.propTypes = {
/**
* Default props.
*
* @type {{icon: null, variant: EmptyStateVariant.small, tableHeading: string}}
* @type {{icon: null, variant: EmptyStateVariant.small, tableHeading: string, ariaLabel: null}}
*/
TableEmpty.defaultProps = {
ariaLabel: null,
icon: SearchIcon,
tableHeading: 'h2',
variant: EmptyStateVariant.small
Expand Down

0 comments on commit dfb0460

Please sign in to comment.