From e1908bfbc5dbfce36e49065293815b66e426818c Mon Sep 17 00:00:00 2001 From: Andreas Molnar Date: Sun, 26 Jul 2026 09:31:26 +0000 Subject: [PATCH] Preview dashboard widget drop target --- .../settings/pages/DashboardWidgetPreview.tsx | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/apps/web/src/components/settings/pages/DashboardWidgetPreview.tsx b/apps/web/src/components/settings/pages/DashboardWidgetPreview.tsx index b7f19a86..5078b13b 100644 --- a/apps/web/src/components/settings/pages/DashboardWidgetPreview.tsx +++ b/apps/web/src/components/settings/pages/DashboardWidgetPreview.tsx @@ -8,7 +8,6 @@ import { DndContext, DragEndEvent, DragOverEvent, - DragOverlay, DragStartEvent, KeyboardSensor, PointerSensor, @@ -958,6 +957,27 @@ export function DashboardWidgetPreview({ return null; }, [activeId, columns, widgetCatalog]); + const renderActiveWidgetPreview = () => { + if (!activeWidget) return null; + + const isLibrary = "key" in activeWidget; + const type = isLibrary ? (activeWidget as WidgetCatalogItem).key : (activeWidget as ColumnWidget).type; + const catalogItem = isLibrary + ? (activeWidget as WidgetCatalogItem) + : widgetCatalog.find((item) => item.key === type); + const params = { + ...(catalogItem?.properties ?? {}), + ...("properties" in activeWidget ? (activeWidget as ColumnWidget).properties : {}), + ...((activeWidget as ColumnWidget).input ?? {}), + }; + + return ( +
+ {renderWidget({ type, params, className: "h-[90px] w-full", isPreview: true })} +
+ ); + }; + const handleDragStart = (event: DragStartEvent) => { setActiveId(String(event.active.id)); setDragOver(null); @@ -1100,7 +1120,9 @@ export function DashboardWidgetPreview({
{/* Drop preview indicator */} {dragOver?.zone === column && dragOver.index === i && ( -
+
+ {renderActiveWidgetPreview()} +
)} +
+ {renderActiveWidgetPreview()} +
)} @@ -1180,26 +1204,6 @@ export function DashboardWidgetPreview({
- {/* Floating drag overlay */} - - {activeWidget && (() => { - const isLibrary = "key" in activeWidget; - const type = isLibrary ? (activeWidget as WidgetCatalogItem).key : (activeWidget as ColumnWidget).type; - const catalogItem = isLibrary - ? (activeWidget as WidgetCatalogItem) - : widgetCatalog.find((i) => i.key === type); - const params = { - ...(catalogItem?.properties ?? {}), - ...("properties" in activeWidget ? (activeWidget as ColumnWidget).properties : {}), - ...((activeWidget as ColumnWidget).input ?? {}), - }; - return ( -
- {renderWidget({ type, params, className: "h-[90px] w-full" })} -
- ); - })()} -