Skip to content

Commit

Permalink
Also fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Sep 13, 2024
1 parent cd69068 commit 2fb1421
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions packages/mui-base/src/utils/useAnchorPositioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,13 @@ export function useAnchorPositioning(
nodeId,
});

// We can assume that element anchors are stable across renders, and thus can be reactive.
const [reactiveAnchorDep, setReactiveAnchorDep] =
React.useState(anchor == null) || ('current' in anchor! && isElement(anchor.current));

React.useEffect(() => {
setReactiveAnchorDep(anchor == null || ('current' in anchor! && isElement(anchor.current)));
}, [anchor, setReactiveAnchorDep]);

useEnhancedEffect(() => {
const resolvedAnchor = typeof anchor === 'function' ? anchor() : anchor;

if (resolvedAnchor) {
refs.setPositionReference(isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor);
}
}, [refs, anchor, reactiveAnchorDep]);
}, [refs, anchor]);

React.useEffect(() => {
if (keepMounted && mounted && elements.domReference && elements.floating) {
Expand Down

0 comments on commit 2fb1421

Please sign in to comment.