Skip to content

Commit d6af26c

Browse files
authored
Merge pull request #93 from toggle-corp/feature/pass-ref-popup-button
Feature/pass ref popup button
2 parents c2d577c + c24d298 commit d6af26c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@togglecorp/toggle-ui",
3-
"version": "0.16.0-beta.6",
3+
"version": "0.16.0-beta.7",
44
"description": "React component library by togglecorp",
55
"files": [
66
"/build"

src/components/PopupButton/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface PopupButtonProps<N extends number | string | undefined> extends
1919
persistent: boolean;
2020
arrowHidden?: boolean;
2121
defaultShown?: boolean;
22+
elementRef?: React.RefObject<HTMLButtonElement>;
2223
}
2324
function PopupButton<N extends number | string | undefined>(props: PopupButtonProps<N>) {
2425
const {
@@ -32,12 +33,15 @@ function PopupButton<N extends number | string | undefined>(props: PopupButtonPr
3233
arrowHidden,
3334
persistent,
3435
defaultShown,
36+
elementRef,
3537
...otherProps
3638
} = props;
3739

38-
const buttonRef = React.useRef<HTMLButtonElement>(null);
40+
const internalButtonRef = React.useRef<HTMLButtonElement>(null);
3941
const popupRef = React.useRef<HTMLDivElement>(null);
4042

43+
const buttonRef = elementRef ?? internalButtonRef;
44+
4145
const [popupShown, setPopupShown] = React.useState(defaultShown ?? false);
4246

4347
useEffect(

0 commit comments

Comments
 (0)