From affe55f01f9a905be90375e64123bad1b2785f87 Mon Sep 17 00:00:00 2001 From: i_nicck Date: Sun, 20 Jul 2025 21:41:09 +0530 Subject: [PATCH 1/5] fix(popover): make PopoverContent children prop optional to fix TS error --- .../components/popover/src/popover-content.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/components/popover/src/popover-content.tsx b/packages/components/popover/src/popover-content.tsx index d0d16420cf..e6b9e45ff8 100644 --- a/packages/components/popover/src/popover-content.tsx +++ b/packages/components/popover/src/popover-content.tsx @@ -15,7 +15,7 @@ import {usePopoverContext} from "./popover-context"; export interface PopoverContentProps extends AriaDialogProps, Omit { - children: ReactNode | ((titleProps: DOMAttributes) => ReactNode); + children?: ReactNode | ((titleProps: DOMAttributes) => ReactNode); } const domAnimation = () => import("@heroui/dom-animation").then((res) => res.default); @@ -50,11 +50,13 @@ const PopoverContent = (props: PopoverContentProps) => { const content = ( <> {!isNonModal && } - -
- {typeof children === "function" ? children(titleProps) : children} -
-
+ {children && ( + +
+ {typeof children === "function" ? children(titleProps) : children} +
+
+ )} ); From 1a6bca773e9d055b065088b22774e6d3ed2ce996 Mon Sep 17 00:00:00 2001 From: i_nicck Date: Sun, 20 Jul 2025 22:52:42 +0530 Subject: [PATCH 2/5] chore(changeset): created changeset --- .changeset/thin-points-sip.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/thin-points-sip.md diff --git a/.changeset/thin-points-sip.md b/.changeset/thin-points-sip.md new file mode 100644 index 0000000000..6baa41c573 --- /dev/null +++ b/.changeset/thin-points-sip.md @@ -0,0 +1,5 @@ +--- +"@heroui/popover": patch +--- + +fix(popover): add null check to PopoverContent children to fix arrow glitch (#4142) From f1eb0824eab1c3559ebfea2a4b460e6117413dcf Mon Sep 17 00:00:00 2001 From: WK Wong Date: Fri, 25 Jul 2025 18:44:18 +0800 Subject: [PATCH 3/5] fix(popover): do not show content when children is null / undefined --- packages/components/popover/src/popover-content.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/components/popover/src/popover-content.tsx b/packages/components/popover/src/popover-content.tsx index e6b9e45ff8..473aa360d8 100644 --- a/packages/components/popover/src/popover-content.tsx +++ b/packages/components/popover/src/popover-content.tsx @@ -47,16 +47,16 @@ const PopoverContent = (props: PopoverContentProps) => { const Component = as || OverlayComponent || "div"; - const content = ( + const content = children && ( <> {!isNonModal && } - {children && ( + {
{typeof children === "function" ? children(titleProps) : children}
- )} + } ); From 81e74230abe76ecfa99fe0e4df40bd211711a595 Mon Sep 17 00:00:00 2001 From: WK Wong Date: Fri, 25 Jul 2025 19:50:09 +0800 Subject: [PATCH 4/5] fix(popover): add test case --- .../popover/__tests__/popover.test.tsx | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/packages/components/popover/__tests__/popover.test.tsx b/packages/components/popover/__tests__/popover.test.tsx index 2b2d36e940..cd8d173c30 100644 --- a/packages/components/popover/__tests__/popover.test.tsx +++ b/packages/components/popover/__tests__/popover.test.tsx @@ -369,3 +369,40 @@ it("should close popover on scroll when shouldCloseOnScroll is false", async () // assert that the popover is still open expect(popover).toHaveAttribute("aria-expanded", "true"); }); + +it("should display popover content only after content is ready", async () => { + jest.useFakeTimers(); + + const TestComponent = () => { + const [content, setContent] = React.useState(""); + + React.useEffect(() => { + const timer = setTimeout(() => { + setContent("test content"); + }, 1000); + + return () => clearTimeout(timer); + }, []); + + return ( + + + + + {content} + + ); + }; + + const wrapper = render(); + + expect(wrapper.queryByTestId("content-test")).not.toBeInTheDocument(); + + act(() => { + jest.advanceTimersByTime(1000); + }); + + expect(wrapper.getByTestId("content-test")).toBeInTheDocument(); + + jest.useRealTimers(); +}); From a45c7e02df805ab1c70fb93c94785a1a0b92c05b Mon Sep 17 00:00:00 2001 From: WK Wong Date: Fri, 25 Jul 2025 19:51:52 +0800 Subject: [PATCH 5/5] chore(changeset): update changeset message --- .changeset/thin-points-sip.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/thin-points-sip.md b/.changeset/thin-points-sip.md index 6baa41c573..8313095ced 100644 --- a/.changeset/thin-points-sip.md +++ b/.changeset/thin-points-sip.md @@ -2,4 +2,4 @@ "@heroui/popover": patch --- -fix(popover): add null check to PopoverContent children to fix arrow glitch (#4142) +fix(popover): arrow glitch in popover content (#4142)