From b676a695730e220293da1de1b5e9e3bcdf5555df Mon Sep 17 00:00:00 2001 From: Josh Black Date: Wed, 30 Aug 2023 14:24:48 -0500 Subject: [PATCH 1/3] fix(ActionList): place `id` on item with role --- src/ActionList/Item.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ActionList/Item.tsx b/src/ActionList/Item.tsx index cbe721b9cfa..ee99ddf030f 100644 --- a/src/ActionList/Item.tsx +++ b/src/ActionList/Item.tsx @@ -183,10 +183,10 @@ export const Item = React.forwardRef( [onSelect, disabled, afterSelect], ) - // use props.id if provided, otherwise generate one. - const labelId = useId(id) - const inlineDescriptionId = useId(id && `${id}--inline-description`) - const blockDescriptionId = useId(id && `${id}--block-description`) + const itemId = useId(id) + const labelId = `${itemId}--label` + const inlineDescriptionId = `${itemId}--inline-description` + const blockDescriptionId = `${itemId}--block-description` const ItemWrapper = _PrivateItemWrapper || React.Fragment @@ -201,6 +201,7 @@ export const Item = React.forwardRef( 'aria-describedby': slots.description?.props.variant === 'block' ? blockDescriptionId : undefined, ...(selectionAttribute && {[selectionAttribute]: selected}), role: role || itemRole, + id: itemId, } const containerProps = _PrivateItemWrapper ? {role: role || itemRole ? 'none' : undefined} : menuItemProps From 2d6386b2fb96e5e16a82f8f6a27d6e743ecaabe7 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Wed, 30 Aug 2023 14:25:34 -0500 Subject: [PATCH 2/3] chore: add changeset --- .changeset/giant-bobcats-deliver.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/giant-bobcats-deliver.md diff --git a/.changeset/giant-bobcats-deliver.md b/.changeset/giant-bobcats-deliver.md new file mode 100644 index 00000000000..ada0448a3f7 --- /dev/null +++ b/.changeset/giant-bobcats-deliver.md @@ -0,0 +1,7 @@ +--- +'@primer/react': patch +--- + +Update ActionList to place `id` on item with an ARIA role + + From fb42cb846c2f77e187c8d0dc484a132aac437139 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Thu, 7 Sep 2023 11:03:04 -0500 Subject: [PATCH 3/3] test: update snapshots and tests with new id --- package-lock.json | 4 +- .../__snapshots__/NavList.test.tsx.snap | 49 +++++++++++-------- .../InlineAutocomplete.test.tsx | 4 +- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 03c7e80ea7c..406995744c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@primer/react", - "version": "35.28.0", + "version": "35.29.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@primer/react", - "version": "35.28.0", + "version": "35.29.0", "license": "MIT", "dependencies": { "@github/combobox-nav": "^2.1.5", diff --git a/src/NavList/__snapshots__/NavList.test.tsx.snap b/src/NavList/__snapshots__/NavList.test.tsx.snap index b50e0e3e252..a8ed9fd5de8 100644 --- a/src/NavList/__snapshots__/NavList.test.tsx.snap +++ b/src/NavList/__snapshots__/NavList.test.tsx.snap @@ -304,9 +304,10 @@ exports[`NavList renders a simple list 1`] = ` >
Home @@ -326,9 +327,10 @@ exports[`NavList renders a simple list 1`] = ` class="c1 c6" >
About @@ -348,9 +350,10 @@ exports[`NavList renders a simple list 1`] = ` class="c1 c6" >
Contact @@ -732,9 +735,10 @@ exports[`NavList renders with groups 1`] = ` >
Getting started @@ -766,22 +770,23 @@ exports[`NavList renders with groups 1`] = ` role="presentation" > Components