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.

Render placement indicator in portal (#1585)

Bogdan Chadkin6820b8d866c6
diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/use-sortable.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/use-sortable.tsx
index 8b5ad189f9..b98a0d588c 100644
--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/use-sortable.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/use-sortable.tsx
@@ -1,4 +1,5 @@
import { useState, useRef } from "react";
+import { createPortal } from "react-dom";
import {
type Placement,
PlacementIndicator,
@@ -105,9 +106,12 @@ export const useSortable = <Item extends { id: string }>({
},
});
- const placementIndicatorElement = placementIndicator ? (
- <PlacementIndicator placement={placementIndicator} />
- ) : undefined;
+ const placementIndicatorElement = placementIndicator
+ ? createPortal(
+ <PlacementIndicator placement={placementIndicator} />,
+ document.body
+ )
+ : undefined;
const sortableRefCallback = (element: HTMLDivElement | null) => {
useDropHandlers.rootRef(element);
diff --git a/apps/builder/app/builder/features/style-panel/style-source/use-sortable.tsx b/apps/builder/app/builder/features/style-panel/style-source/use-sortable.tsx
index 7186ff7542..1b6331fec8 100644
--- a/apps/builder/app/builder/features/style-panel/style-source/use-sortable.tsx
+++ b/apps/builder/app/builder/features/style-panel/style-source/use-sortable.tsx
@@ -1,4 +1,5 @@
import { useState, useRef } from "react";
+import { createPortal } from "react-dom";
import {
type Placement,
PlacementIndicator,
@@ -119,9 +120,12 @@ export const useSortable = <Item extends { id: string }>({
},
});
- const placementIndicatorElement = placementIndicator ? (
- <PlacementIndicator placement={placementIndicator} />
- ) : undefined;
+ const placementIndicatorElement = placementIndicator
+ ? createPortal(
+ <PlacementIndicator placement={placementIndicator} />,
+ document.body
+ )
+ : undefined;
const sortableRefCallback = (element: HTMLDivElement | null) => {
useDropHandlers.rootRef(element);