Skip to content

Commit 75e709e

Browse files
committed
fix(Popover): Update component to forward ref
1 parent 56ff1c0 commit 75e709e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

.changeset/hot-jobs-marry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": minor
3+
---
4+
5+
Add forward ref to Popover

packages/react/src/Popover/Popover.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,16 @@ export type PopoverProps = {
5353
} & StyledPopoverProps &
5454
HTMLProps<HTMLDivElement>
5555

56-
const Popover: React.FC<React.PropsWithChildren<PopoverProps>> = ({
57-
className,
58-
caret = 'top',
59-
open,
60-
relative,
61-
...props
62-
}) => {
56+
const Popover = React.forwardRef<HTMLElement, PopoverProps>(function Popover(
57+
{className, caret = 'top', open, relative, ...props},
58+
forwardRef,
59+
) {
6360
const enabled = useFeatureFlag(CSS_MODULES_FLAG)
6461
if (enabled) {
6562
return (
6663
<BaseComponent
6764
{...props}
65+
ref={forwardRef}
6866
data-open={open ? '' : undefined}
6967
data-relative={relative ? '' : undefined}
7068
data-caret={caret}
@@ -74,7 +72,8 @@ const Popover: React.FC<React.PropsWithChildren<PopoverProps>> = ({
7472
}
7573

7674
return <BaseComponent {...props} className={className} caret={caret} open={open} relative={relative} />
77-
}
75+
})
76+
Popover.displayName = 'Popover'
7877

7978
const StyledPopoverContent = toggleStyledComponent(
8079
CSS_MODULES_FLAG,

0 commit comments

Comments
 (0)