Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/orthogroup-tree-table' into orth…
Browse files Browse the repository at this point in the history
…ogroup-tree-table__1254-fixes
  • Loading branch information
bobular committed Nov 1, 2024
2 parents 6907790 + 5bd7d1c commit 494e55d
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useMemo,
forwardRef,
useImperativeHandle,
useCallback,
} from 'react';
import { Popover } from '@material-ui/core';
import SwissArmyButton from '../SwissArmyButton';
Expand Down Expand Up @@ -117,15 +118,19 @@ const PopoverButton = forwardRef<PopoverButtonHandle, PopoverButtonProps>(
[styleOverrides]
);

const onCloseHandler = () => {
const onCloseHandler = useCallback(() => {
setAnchorEl(null);
onClose && onClose();
};
}, [onClose]);

// Expose the `close()` method to external components via ref
useImperativeHandle(ref, () => ({
close: onCloseHandler,
}));
useImperativeHandle(
ref,
() => ({
close: onCloseHandler,
}),
[onCloseHandler]
);

useEffect(() => {
if (!setIsPopoverOpen) return;
Expand Down

0 comments on commit 494e55d

Please sign in to comment.