From 8c8e942d4c6c50c6e4e77640cc62a9ab56ff472c Mon Sep 17 00:00:00 2001 From: Jesse Hull Date: Mon, 6 Mar 2023 15:35:16 -0500 Subject: [PATCH] refactor(StructuredList): ariaLabel to aria-label (#13261) * refactor(StructuredListWrapper): ariaLabel to aria-label * fix(StructuredList test): use 'aria-label' --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../__snapshots__/PublicAPI-test.js.snap | 5 +++-- .../StructuredList/StructuredList-test.js | 2 +- .../StructuredList/StructuredList.js | 22 +++++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index a72fca38f3fe..a4b03ffa35aa 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -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", }, diff --git a/packages/react/src/components/StructuredList/StructuredList-test.js b/packages/react/src/components/StructuredList/StructuredList-test.js index 32fa31a096cd..d63aa53e804f 100644 --- a/packages/react/src/components/StructuredList/StructuredList-test.js +++ b/packages/react/src/components/StructuredList/StructuredList-test.js @@ -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', () => { diff --git a/packages/react/src/components/StructuredList/StructuredList.js b/packages/react/src/components/StructuredList/StructuredList.js index 9e0e4b339136..8a8f6cb5d35d 100644 --- a/packages/react/src/components/StructuredList/StructuredList.js +++ b/packages/react/src/components/StructuredList/StructuredList.js @@ -20,7 +20,8 @@ export function StructuredListWrapper(props) { children, selection, className, - ariaLabel, + ['aria-label']: ariaLabel, + ariaLabel: deprecatedAriaLabel, isCondensed, isFlush, ...other @@ -36,7 +37,11 @@ export function StructuredListWrapper(props) { return ( -
+
{children}
@@ -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 @@ -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) {