Skip to content

Commit

Permalink
fix(SelectPanel): pass anchorId to AnchoredOverlay (#5549)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
francinelucca authored Jan 23, 2025
1 parent bd405df commit 16c572e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-ducks-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

fix(SelectPanel): pass anchorId to AnchoredOverlay
Original file line number Diff line number Diff line change
Expand Up @@ -314,18 +314,19 @@ export const WithSelectPanel = () => {

return (
<FormControl required>
<FormControl.Label>Select Labels</FormControl.Label>
<FormControl.Label id="select_panel_label">Select Labels</FormControl.Label>
<SelectPanel
title="Select labels"
subtitle="Use labels to organize issues and pull requests"
renderAnchor={({children, 'aria-labelledby': ariaLabelledBy, ...anchorProps}) => (
renderAnchor={({children, id, ...anchorProps}) => (
<Button
trailingAction={TriangleDownIcon}
aria-labelledby={` ${ariaLabelledBy}`}
aria-labelledby={`select_panel_label selectpanel_wrapper`}
id={id}
{...anchorProps}
aria-haspopup="dialog"
>
{children ?? 'Select Labels'}
<span id="selectpanel_wrapper">{children ?? 'Select Labels'}</span>
</Button>
)}
open={open}
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/SelectPanel/SelectPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export function SelectPanel({
overlayProps,
sx,
className,
id,
...listProps
}: SelectPanelProps): JSX.Element {
const titleId = useId()
Expand Down Expand Up @@ -213,6 +214,7 @@ export function SelectPanel({
}}
focusTrapSettings={focusTrapSettings}
focusZoneSettings={focusZoneSettings}
anchorId={id}
>
<LiveRegionOutlet />
{usingModernActionList ? null : (
Expand Down

0 comments on commit 16c572e

Please sign in to comment.