Skip to content

Commit caba744

Browse files
chore: anchor updates for menu components
1 parent 7a961de commit caba744

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

packages/@primereact/headless/src/popover/usePopover.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,19 @@ export const usePopover = withHeadless({
5656
const setAnchorFallbackRef = React.useCallback((node: HTMLElement | null) => {
5757
const element = toElement(node) ?? null;
5858

59-
if (!element || element === anchorFallbackRef.current) return;
59+
if (element === anchorFallbackRef.current) return;
6060

6161
anchorFallbackRef.current = element;
6262

63+
if (!element) {
64+
if (anchorRef.current && !anchorRef.current.isConnected) {
65+
anchorRef.current = null;
66+
setAnchorElement(null);
67+
}
68+
69+
return;
70+
}
71+
6372
if (!anchorRef.current) {
6473
anchorRef.current = element;
6574
setAnchorElement(element);

0 commit comments

Comments
 (0)