Skip to content

Commit

Permalink
refactor(StructuredList): ariaLabel to aria-label (#13261)
Browse files Browse the repository at this point in the history
* refactor(StructuredListWrapper): ariaLabel to aria-label

* fix(StructuredList test): use 'aria-label'

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
jsehull and kodiakhq[bot] committed Mar 6, 2023
1 parent 479172c commit 8c8e942
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6891,15 +6891,16 @@ Map {
},
"StructuredListWrapper" => Object {
"defaultProps": Object {
"ariaLabel": "Structured list section",
"aria-label": "Structured list section",
"isCondensed": false,
"isFlush": false,
"selection": false,
},
"propTypes": Object {
"ariaLabel": Object {
"aria-label": Object {
"type": "string",
},
"ariaLabel": [Function],
"children": Object {
"type": "node",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('StructuredList', () => {
});
it('should allow a custom aria label to be passed in', () => {
const testAriaLabel = 'custom-test-aria-label';
renderComponent({ wrapperProps: { ariaLabel: testAriaLabel } });
renderComponent({ wrapperProps: { 'aria-label': testAriaLabel } });
expect(screen.getByLabelText(testAriaLabel)).toBeInTheDocument();
});
it('should check that children are rendered', () => {
Expand Down
22 changes: 18 additions & 4 deletions packages/react/src/components/StructuredList/StructuredList.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export function StructuredListWrapper(props) {
children,
selection,
className,
ariaLabel,
['aria-label']: ariaLabel,
ariaLabel: deprecatedAriaLabel,
isCondensed,
isFlush,
...other
Expand All @@ -36,7 +37,11 @@ export function StructuredListWrapper(props) {
return (
<GridSelectedRowStateContext.Provider value={selectedRow}>
<GridSelectedRowDispatchContext.Provider value={setSelectedRow}>
<div role="table" className={classes} {...other} aria-label={ariaLabel}>
<div
role="table"
className={classes}
{...other}
aria-label={deprecatedAriaLabel || ariaLabel}>
{children}
</div>
</GridSelectedRowDispatchContext.Provider>
Expand All @@ -48,7 +53,16 @@ StructuredListWrapper.propTypes = {
/**
* Specify a label to be read by screen readers on the container node
*/
ariaLabel: PropTypes.string,
['aria-label']: PropTypes.string,

/**
* Deprecated, please use `aria-label` instead.
* Specify a label to be read by screen readers on the container note.
*/
ariaLabel: deprecate(
PropTypes.string,
'This prop syntax has been deprecated. Please use the new `aria-label`.'
),

/**
* Provide the contents of your StructuredListWrapper
Expand Down Expand Up @@ -80,7 +94,7 @@ StructuredListWrapper.defaultProps = {
selection: false,
isCondensed: false,
isFlush: false,
ariaLabel: 'Structured list section',
['aria-label']: 'Structured list section',
};

export function StructuredListHead(props) {
Expand Down

0 comments on commit 8c8e942

Please sign in to comment.