diff --git a/app/components/Editor.tsx b/app/components/Editor.tsx index b0e8235dd..195042df2 100644 --- a/app/components/Editor.tsx +++ b/app/components/Editor.tsx @@ -350,6 +350,7 @@ function Editor(props: Props, ref: React.RefObject | null) { )} {activeLinkElement && !shareId && ( diff --git a/app/components/HoverPreview.tsx b/app/components/HoverPreview.tsx index bd15ed46a..2c7fbdbab 100644 --- a/app/components/HoverPreview.tsx +++ b/app/components/HoverPreview.tsx @@ -14,11 +14,15 @@ const DELAY_OPEN = 300; const DELAY_CLOSE = 300; type Props = { + /* The document associated with the editor, if any */ + id?: string; + /* The HTML element that is being hovered over */ element: HTMLAnchorElement; + /* A callback on close of the hover preview */ onClose: () => void; }; -function HoverPreviewInternal({ element, onClose }: Props) { +function HoverPreviewInternal({ element, id, onClose }: Props) { const { documents } = useStores(); const slug = parseDocumentSlug(element.href); const [isVisible, setVisible] = React.useState(false); @@ -104,7 +108,7 @@ function HoverPreviewInternal({ element, onClose }: Props) { aria-hidden >
- + {(content: React.ReactNode) => isVisible ? ( diff --git a/app/components/HoverPreviewDocument.tsx b/app/components/HoverPreviewDocument.tsx index a4c6238c7..874a5cb1e 100644 --- a/app/components/HoverPreviewDocument.tsx +++ b/app/components/HoverPreviewDocument.tsx @@ -9,11 +9,14 @@ import Editor from "~/components/Editor"; import useStores from "~/hooks/useStores"; type Props = { + /* The document associated with the editor, if any */ + id?: string; + /* The URL we want a preview for */ url: string; children: (content: React.ReactNode) => React.ReactNode; }; -function HoverPreviewDocument({ url, children }: Props) { +function HoverPreviewDocument({ url, id, children }: Props) { const { documents } = useStores(); const slug = parseDocumentSlug(url); @@ -22,7 +25,7 @@ function HoverPreviewDocument({ url, children }: Props) { } const document = slug ? documents.getByUrl(slug) : undefined; - if (!document) { + if (!document || document.id === id) { return null; }