Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-ducks-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

fix(AnchoredOverlay): Omit aria-label and aria-labelledby from renderAnchor props
4 changes: 3 additions & 1 deletion packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ interface AnchoredOverlayPropsWithAnchor {
* A custom function component used to render the anchor element.
* Will receive the selected text as `children` prop when an item is activated.
*/
renderAnchor: <T extends React.HTMLAttributes<HTMLElement>>(props: T) => JSX.Element
renderAnchor: <T extends Omit<React.HTMLAttributes<HTMLElement>, 'aria-label' | 'aria-labelledby'>>(
props: T,
) => JSX.Element

/**
* An override to the internal ref that will be spread on to the renderAnchor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {InfoIcon} from '@primer/octicons-react'
import {AnchoredOverlay, IconButton} from '..'

export function itemWithIconElements() {
return (
<AnchoredOverlay open={true} renderAnchor={props => <IconButton {...props} icon={InfoIcon} aria-label="Info" />}>
<p>GitHub</p>
</AnchoredOverlay>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ export const HeightInitialWithUnderflowingItemsAfterFetch = () => {
<FormControl>
<FormControl.Label>Labels</FormControl.Label>
<SelectPanel
renderAnchor={({children, 'aria-labelledby': ariaLabelledBy, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} aria-labelledby={` ${ariaLabelledBy}`} {...anchorProps}>
renderAnchor={({children, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} {...anchorProps}>
{children}
</Button>
)}
Expand Down Expand Up @@ -172,8 +172,8 @@ export const AboveTallBody = () => {
<FormControl>
<FormControl.Label>Labels</FormControl.Label>
<SelectPanel
renderAnchor={({children, 'aria-labelledby': ariaLabelledBy, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} aria-labelledby={` ${ariaLabelledBy}`} {...anchorProps}>
renderAnchor={({children, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} {...anchorProps}>
{children}
</Button>
)}
Expand Down
22 changes: 6 additions & 16 deletions packages/react/src/SelectPanel/SelectPanel.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,8 @@ export const AsyncFetch: StoryObj<SelectPanelProps> = {
<SelectPanel
title="Select labels"
subtitle="Use labels to organize issues and pull requests"
renderAnchor={({children, 'aria-labelledby': ariaLabelledBy, ...anchorProps}) => (
<Button
trailingAction={TriangleDownIcon}
aria-labelledby={` ${ariaLabelledBy}`}
{...anchorProps}
aria-haspopup="dialog"
>
renderAnchor={({children, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} {...anchorProps} aria-haspopup="dialog">
{children ?? 'Select Labels'}
</Button>
)}
Expand Down Expand Up @@ -656,8 +651,8 @@ export const CustomisedNoInitialItems = () => {
<ToggleSwitch onClick={onClick} checked={isError} aria-labelledby="toggle" />
<SelectPanel
title="Set projects"
renderAnchor={({children, 'aria-labelledby': ariaLabelledBy, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} aria-labelledby={` ${ariaLabelledBy}`} {...anchorProps}>
renderAnchor={({children, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} {...anchorProps}>
{children ?? 'Select Labels'}
</Button>
)}
Expand Down Expand Up @@ -709,13 +704,8 @@ export const CustomisedNoResults: StoryObj<typeof SelectPanel> = {
<SelectPanel
title="Select labels"
subtitle="Use labels to organize issues and pull requests"
renderAnchor={({children, 'aria-labelledby': ariaLabelledBy, ...anchorProps}) => (
<Button
trailingAction={TriangleDownIcon}
aria-labelledby={` ${ariaLabelledBy}`}
{...anchorProps}
aria-haspopup="dialog"
>
renderAnchor={({children, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} {...anchorProps} aria-haspopup="dialog">
{children ?? 'Select Labels'}
</Button>
)}
Expand Down
Loading