Skip to content
This repository was archived by the owner on Mar 25, 2023. It is now read-only.

Commit 655e570

Browse files
onpawsmilesrichardson
authored andcommitted
PopoutBox accepts optional ref from parent
1 parent a5bce52 commit 655e570

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tdesign/src/PopoutBox/PopoutBox.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface IPopoutBoxProps {
2929
popoutContainerStyle?: SystemStyleObject;
3030
anchorPosition?: PopoutAnchorPosition;
3131
buttonProps?: any;
32+
ref?: React.RefObject<HTMLDivElement>
3233
}
3334

3435
const getAnchorPositionStyle = (
@@ -97,9 +98,10 @@ export default ({
9798
popoutContainerStyle = {},
9899
anchorPosition,
99100
buttonProps = {},
101+
ref
100102
}: IPopoutBoxProps) => {
101103
const [isOpen, setIsOpen] = React.useState(false);
102-
const containerRef = React.useRef<HTMLDivElement>(null);
104+
const containerRef = ref || React.useRef<HTMLDivElement>(null);
103105

104106
const anchorPositionStyle = getAnchorPositionStyle(anchorPosition);
105107

0 commit comments

Comments
 (0)