From a1f75dfed33c6c3d2d7a95ca48b93ffcac81589c Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Wed, 11 Jun 2025 10:40:48 +0500 Subject: [PATCH] editor: fix search popup removed on link hover --- .../src/components/popup-presenter/index.tsx | 13 ++++++++----- packages/editor/src/toolbar/utils/dom.ts | 14 +++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/editor/src/components/popup-presenter/index.tsx b/packages/editor/src/components/popup-presenter/index.tsx index 5465f15ca..214393404 100644 --- a/packages/editor/src/components/popup-presenter/index.tsx +++ b/packages/editor/src/components/popup-presenter/index.tsx @@ -26,15 +26,17 @@ import { import { getPopupContainer, getPopupRoot, - getToolbarElement, - unmountPopupRoot + getToolbarElement } from "../../toolbar/utils/dom.js"; import { useIsMobile, useToolbarStore } from "../../toolbar/stores/toolbar-store.js"; import React from "react"; -import { ResponsivePresenter, ResponsivePresenterProps } from "../responsive/index.js"; +import { + ResponsivePresenter, + ResponsivePresenterProps +} from "../responsive/index.js"; export type PopupWrapperProps = UsePopupHandlerOptions & { autoCloseOnUnmount?: boolean; @@ -106,11 +108,12 @@ type ShowPopupOptions = { export function showPopup(options: ShowPopupOptions) { const { popup, ...props } = options; + const root = getPopupRoot(); function hide() { - unmountPopupRoot(); + root.unmount(); } - getPopupRoot().render( + root.render( . */ -import { createRoot, Root } from "react-dom/client"; +import { createRoot } from "react-dom/client"; export function getToolbarElement() { return ( @@ -48,13 +48,9 @@ export function getEditorDOM() { getEditorContainer()) as HTMLElement; // ProseMirror } -let popupRoot: Root | undefined = undefined; export function getPopupRoot() { - if (!popupRoot) popupRoot = createRoot(getPopupContainer()); - return popupRoot; -} - -export function unmountPopupRoot() { - if (popupRoot) popupRoot.unmount(); - popupRoot = undefined; + const container = getPopupContainer(); + const div = document.createElement("div"); + container.appendChild(div); + return createRoot(div); }