Skip to content

Commit 16c572e

Browse files
authoredJan 23, 2025··
fix(SelectPanel): pass anchorId to AnchoredOverlay (#5549)
* fix(SelectPanel): pass anchorId to AnchoredOverlay * Create tricky-ducks-pretend.md * docs(FormControl): correct selectPanel example aria-labelledby * docs(FormControl): small fix to selectPanel story
1 parent bd405df commit 16c572e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed
 

‎.changeset/tricky-ducks-pretend.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
fix(SelectPanel): pass anchorId to AnchoredOverlay

‎packages/react/src/FormControl/FormControl.features.stories.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,19 @@ export const WithSelectPanel = () => {
314314

315315
return (
316316
<FormControl required>
317-
<FormControl.Label>Select Labels</FormControl.Label>
317+
<FormControl.Label id="select_panel_label">Select Labels</FormControl.Label>
318318
<SelectPanel
319319
title="Select labels"
320320
subtitle="Use labels to organize issues and pull requests"
321-
renderAnchor={({children, 'aria-labelledby': ariaLabelledBy, ...anchorProps}) => (
321+
renderAnchor={({children, id, ...anchorProps}) => (
322322
<Button
323323
trailingAction={TriangleDownIcon}
324-
aria-labelledby={` ${ariaLabelledBy}`}
324+
aria-labelledby={`select_panel_label selectpanel_wrapper`}
325+
id={id}
325326
{...anchorProps}
326327
aria-haspopup="dialog"
327328
>
328-
{children ?? 'Select Labels'}
329+
<span id="selectpanel_wrapper">{children ?? 'Select Labels'}</span>
329330
</Button>
330331
)}
331332
open={open}

‎packages/react/src/SelectPanel/SelectPanel.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export function SelectPanel({
102102
overlayProps,
103103
sx,
104104
className,
105+
id,
105106
...listProps
106107
}: SelectPanelProps): JSX.Element {
107108
const titleId = useId()
@@ -213,6 +214,7 @@ export function SelectPanel({
213214
}}
214215
focusTrapSettings={focusTrapSettings}
215216
focusZoneSettings={focusZoneSettings}
217+
anchorId={id}
216218
>
217219
<LiveRegionOutlet />
218220
{usingModernActionList ? null : (

0 commit comments

Comments
 (0)
Please sign in to comment.