Skip to content

Commit

Permalink
[pkg/core,#451][s]: fix tooltip render for empty pages
Browse files Browse the repository at this point in the history
  • Loading branch information
khalilcodes authored and olayway committed Apr 6, 2023
1 parent b6febb0 commit a667d8f
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/core/src/ui/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const Tooltip: React.FC<Props> = ({
const arrowRef = useRef(null);
const [showTooltip, setShowTooltip] = useState(false);
const [tooltipData, setTooltipData] = useState({
content: <Fragment />,
content: null || <Fragment />,
image: "",
});
const [tooltipContentLoaded, setTooltipContentLoaded] = useState(false);
Expand Down Expand Up @@ -131,7 +131,7 @@ export const Tooltip: React.FC<Props> = ({

const page = data.find((p) => p._raw.flattenedPath === filePath);

if (page) {
if (page && page.body.code.length > 0) {
const Component = usehook(page.body.code);
PageContent = Component;
image = page.image ?? "";
Expand Down Expand Up @@ -159,14 +159,14 @@ export const Tooltip: React.FC<Props> = ({
}}
/>
);
}

setTooltipData({
content: Body,
image: image,
});
setTooltipData({
content: Body,
image: image,
});

setTooltipContentLoaded(true);
setTooltipContentLoaded(true);
}
};

useEffect(() => {
Expand Down Expand Up @@ -200,9 +200,11 @@ export const Tooltip: React.FC<Props> = ({
height={100}
/>
)}
<div className="tooltip-body" style={tooltipBodyStyle(theme)}>
{tooltipData.content}
</div>
{tooltipData.content && (
<div className="tooltip-body" style={tooltipBodyStyle(theme)}>
{tooltipData.content}
</div>
)}
</div>
<div
ref={arrowRef}
Expand Down

0 comments on commit a667d8f

Please sign in to comment.