Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

create probe lazily because of SSR

Roman Pominov2a8a8635dec1
diff --git a/apps/designer/app/shared/design-system/components/primitives/dnd/placement.tsx b/apps/designer/app/shared/design-system/components/primitives/dnd/placement.tsx
index a20a29d724..9dac65f42d 100644
--- a/apps/designer/app/shared/design-system/components/primitives/dnd/placement.tsx
+++ b/apps/designer/app/shared/design-system/components/primitives/dnd/placement.tsx
@@ -4,7 +4,13 @@ import { Box } from "../../box";
export type Rect = Pick<DOMRect, "top" | "left" | "width" | "height">;
type Point = { x: number; y: number };
-const probe = document.createElement("div");
+let probeCache: undefined | HTMLElement;
+const getProbe = () => {
+ if (probeCache === undefined) {
+ probeCache = document.createElement("div");
+ }
+ return probeCache;
+};
/**
* We place a div at the position where future drop will happen.
@@ -17,6 +23,7 @@ const getPlacement = ({
target: HTMLElement;
index?: number;
}) => {
+ const probe = getProbe();
const { children } = target;
if (index > children.length - 1) {
target.appendChild(probe);