Skip to content

Commit

Permalink
update portal logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Sep 15, 2024
1 parent 4312282 commit 85f77e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/mui-base/src/Portal/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ const Portal = React.forwardRef(function Portal(
) {
const { children, container, disablePortal = false } = props;
const [mountNode, setMountNode] = React.useState<ReturnType<typeof getContainer>>(null);
// @ts-expect-error
const handleRef = useForkRef(getReactElementRef(children), forwardedRef);

const handleRef = useForkRef(
React.isValidElement(children) ? getReactElementRef(children) : null,
forwardedRef,
);

useEnhancedEffect(() => {
if (!disablePortal) {
Expand Down
7 changes: 5 additions & 2 deletions packages/mui-material/src/Portal/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ const Portal = React.forwardRef(function Portal(
) {
const { children, container, disablePortal = false } = props;
const [mountNode, setMountNode] = React.useState<ReturnType<typeof getContainer>>(null);
// @ts-expect-error
const handleRef = useForkRef(getReactElementRef(children), forwardedRef);

const handleRef = useForkRef(
React.isValidElement(children) ? getReactElementRef(children) : null,
forwardedRef,
);

useEnhancedEffect(() => {
if (!disablePortal) {
Expand Down

0 comments on commit 85f77e1

Please sign in to comment.