From 3ce5cd48871a0bbf8982e5a6d2d1ce6214124e49 Mon Sep 17 00:00:00 2001 From: Uyarn Date: Thu, 1 Aug 2024 16:41:53 +0800 Subject: [PATCH] fix(Popup): null component as content --- src/popup/Popup.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/popup/Popup.tsx b/src/popup/Popup.tsx index ecf031ee43..3ea3b3d078 100644 --- a/src/popup/Popup.tsx +++ b/src/popup/Popup.tsx @@ -84,7 +84,10 @@ const Popup = forwardRef((originalProps, ref) => { // 判断展示浮层 const showOverlay = useMemo(() => { - if (hideEmptyPopup && !content) return false; + const isNullComponent = + React.Children.map(content, (child) => React.isValidElement(child) && (child.type as Function)?.(child.props)) + .length === 0; + if (hideEmptyPopup && (!content || isNullComponent)) return false; return visible || popupElement; }, [hideEmptyPopup, content, visible, popupElement]);