Skip to content

Commit

Permalink
fix: undo menu changes and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonjoseph committed Mar 19, 2024
1 parent 332501f commit 9e44c41
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions packages/react/src/components/Menu/Menu.tsx
Expand Up @@ -24,7 +24,6 @@ import { keys, match } from '../../internal/keyboard';
import { useMergedRefs } from '../../internal/useMergedRefs';
import { usePrefix } from '../../internal/usePrefix';
import { warning } from '../../internal/warning.js';
import useIsomorphicEffect from '../../internal/useIsomorphicEffect';

import { MenuContext, menuReducer } from './MenuContext';
import { useLayoutDirection } from '../LayoutDirection';
Expand Down Expand Up @@ -113,7 +112,9 @@ const Menu = forwardRef<HTMLUListElement, MenuProps>(function Menu(
onOpen,
open,
size = 'sm',
target,
// TODO: #16004
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
target = document.body,
x = 0,
y = 0,
...rest
Expand All @@ -122,13 +123,6 @@ const Menu = forwardRef<HTMLUListElement, MenuProps>(function Menu(
) {
const prefix = usePrefix();

const [newTarget, setNewTarget] = useState(target);
useIsomorphicEffect(() => {
if (!target) {
setNewTarget(document.body);
}
}, [target]);

const focusReturn = useRef<HTMLElement | null>(null);

const context = useContext(MenuContext);
Expand Down Expand Up @@ -443,9 +437,7 @@ const Menu = forwardRef<HTMLUListElement, MenuProps>(function Menu(
</MenuContext.Provider>
);

return isRoot
? (open && createPortal(rendered, newTarget)) || null
: rendered;
return isRoot ? (open && createPortal(rendered, target)) || null : rendered;
});

Menu.propTypes = {
Expand Down

0 comments on commit 9e44c41

Please sign in to comment.