You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by en...@apache.org on 2026/07/08 12:27:17 UTC

(superset) branch enxdev/fix/dnd-drag-and-drop created (now f12e71a1084)

This is an automated email from the ASF dual-hosted git repository.

EnxDev pushed a change to branch enxdev/fix/dnd-drag-and-drop
in repository https://gitbox.apache.org/repos/asf/superset.git


      at f12e71a1084 fix(explore): render DragOverlay so dragged metric/column is visible

This branch includes the following new commits:

     new f12e71a1084 fix(explore): render DragOverlay so dragged metric/column is visible

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: fix(explore): render DragOverlay so dragged metric/column is visible

Posted by en...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

EnxDev pushed a commit to branch enxdev/fix/dnd-drag-and-drop
in repository https://gitbox.apache.org/repos/asf/superset.git

commit f12e71a1084f356ca6f4a681cf9338886855fba9
Author: Enzo Martellucci <en...@gmail.com>
AuthorDate: Wed Jul 8 14:26:47 2026 +0200

    fix(explore): render DragOverlay so dragged metric/column is visible
---
 .../ExploreContainer/ExploreDndContext.tsx         | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/superset-frontend/src/explore/components/ExploreContainer/ExploreDndContext.tsx b/superset-frontend/src/explore/components/ExploreContainer/ExploreDndContext.tsx
index 3d4b3d7ccac..a46b132309c 100644
--- a/superset-frontend/src/explore/components/ExploreContainer/ExploreDndContext.tsx
+++ b/superset-frontend/src/explore/components/ExploreContainer/ExploreDndContext.tsx
@@ -27,6 +27,7 @@ import {
 } from 'react';
 import {
   DndContext,
+  DragOverlay,
   useSensor,
   useSensors,
   PointerSensor,
@@ -36,6 +37,18 @@ import {
   UniqueIdentifier,
 } from '@dnd-kit/core';
 import { sortableKeyboardCoordinates } from '@dnd-kit/sortable';
+import { css, styled } from '@apache-superset/core/theme';
+import {
+  ColumnOptionProps,
+  MetricOptionProps,
+} from '@superset-ui/chart-controls';
+import { Flex } from '@superset-ui/core/components';
+import { Icons } from '@superset-ui/core/components/Icons';
+import { DndItemType } from 'src/explore/components/DndItemType';
+import {
+  StyledColumnOption,
+  StyledMetricOption,
+} from 'src/explore/components/optionRenderers';
 import { DatasourcePanelDndItem } from '../DatasourcePanel/types';
 
 /**
@@ -51,6 +64,30 @@ export interface ActiveDragData {
   onDropLabel?: () => void;
 }
 
+/**
+ * Container for the <DragOverlay> preview. Mirrors DatasourceItemContainer
+ * (the lifted row from DatasourcePanelDragOption) so the item following the
+ * cursor reads as the raised source row. Fully opaque on purpose — the faded
+ * source row is what signals "in flight", not the overlay.
+ */
+const DragOverlayContainer = styled(Flex)`
+  ${({ theme }) => css`
+    width: 100%;
+    height: ${theme.sizeUnit * 6}px;
+    padding: 0 ${theme.sizeUnit}px;
+    color: ${theme.colorText};
+    background-color: ${theme.colorBgElevated};
+    border-radius: 4px;
+    box-shadow: 0 2px 8px ${theme.colorSplit};
+    cursor: grabbing;
+
+    > div {
+      min-width: 0;
+      margin-right: ${theme.sizeUnit * 2}px;
+    }
+  `}
+`;
+
 /**
  * Context to track if something is being dragged (for visual feedback)
  */
@@ -229,6 +266,30 @@ export const ExploreDndContextProvider: FC<ExploreDndContextProps> = ({
           </ActiveDragContext.Provider>
         </DraggingContext.Provider>
       </DropzoneContext.Provider>
+      {/*
+        @dnd-kit has no native drag image (unlike react-dnd's HTML5 backend),
+        so the item following the cursor must be rendered explicitly here.
+        Reorder drags leave activeData null on purpose, so only external
+        DatasourcePanel drags (which carry a value) get a preview.
+      */}
+      <DragOverlay dropAnimation={null}>
+        {activeData?.value ? (
+          <DragOverlayContainer align="center" justify="space-between">
+            {activeData.type === DndItemType.Column ? (
+              <StyledColumnOption
+                column={activeData.value as ColumnOptionProps['column']}
+                showType
+              />
+            ) : (
+              <StyledMetricOption
+                metric={activeData.value as MetricOptionProps['metric']}
+                showType
+              />
+            )}
+            <Icons.Drag iconSize="xl" />
+          </DragOverlayContainer>
+        ) : null}
+      </DragOverlay>
     </DndContext>
   );
 };