From 29a07c2c27965c89465808713909c8474d0a7b5c Mon Sep 17 00:00:00 2001 From: erkanercan Date: Sat, 7 Jan 2023 12:30:51 +0300 Subject: [PATCH 1/2] fix: aria label added to ungrouped simple list --- .../src/components/SimpleList/SimpleList.tsx | 2 +- .../SimpleList/__tests__/SimpleList.test.tsx | 5 +++ .../__snapshots__/SimpleList.test.tsx.snap | 44 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/packages/react-core/src/components/SimpleList/SimpleList.tsx b/packages/react-core/src/components/SimpleList/SimpleList.tsx index 874c722bb4e..c7aedb25edc 100644 --- a/packages/react-core/src/components/SimpleList/SimpleList.tsx +++ b/packages/react-core/src/components/SimpleList/SimpleList.tsx @@ -74,7 +74,7 @@ export class SimpleList extends React.Component
{isGrouped && children} - {!isGrouped &&
    {children}
} + {!isGrouped &&
    {children}
}
); diff --git a/packages/react-core/src/components/SimpleList/__tests__/SimpleList.test.tsx b/packages/react-core/src/components/SimpleList/__tests__/SimpleList.test.tsx index 185c4828cf2..3b81ee074e2 100644 --- a/packages/react-core/src/components/SimpleList/__tests__/SimpleList.test.tsx +++ b/packages/react-core/src/components/SimpleList/__tests__/SimpleList.test.tsx @@ -31,6 +31,11 @@ describe('SimpleList', () => { expect(asFragment()).toMatchSnapshot(); }); + test('renders aria-labelled content', () => { + const { asFragment } = render({items}); + expect(asFragment()).toMatchSnapshot(); + }); + test('renders grouped content', () => { const { asFragment } = render( diff --git a/packages/react-core/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap b/packages/react-core/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap index f6fd48f2e33..b46cb5fe70a 100644 --- a/packages/react-core/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap +++ b/packages/react-core/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap @@ -1,5 +1,49 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`SimpleList renders aria-labelled content 1`] = ` + +
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+`; + exports[`SimpleList renders content 1`] = `
Date: Mon, 9 Jan 2023 23:55:47 +0300 Subject: [PATCH 2/2] refactor: added aria label to props list, also described it --- .../react-core/src/components/SimpleList/SimpleList.tsx | 6 ++++-- .../__tests__/__snapshots__/SimpleList.test.tsx.snap | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-core/src/components/SimpleList/SimpleList.tsx b/packages/react-core/src/components/SimpleList/SimpleList.tsx index c7aedb25edc..a8145419797 100644 --- a/packages/react-core/src/components/SimpleList/SimpleList.tsx +++ b/packages/react-core/src/components/SimpleList/SimpleList.tsx @@ -16,6 +16,8 @@ export interface SimpleListProps extends Omit, ' ) => void; /** Indicates whether component is controlled by its internal state */ isControlled?: boolean; + /** aria-label for the
    element that wraps the SimpleList items. */ + 'aria-label'?: string; } export interface SimpleListState { @@ -57,7 +59,7 @@ export class SimpleList extends React.Component
    {isGrouped && children} - {!isGrouped &&
      {children}
    } + {!isGrouped &&
      {children}
    }
    ); diff --git a/packages/react-core/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap b/packages/react-core/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap index b46cb5fe70a..f46fac8cb1d 100644 --- a/packages/react-core/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap +++ b/packages/react-core/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap @@ -3,7 +3,6 @@ exports[`SimpleList renders aria-labelled content 1`] = `