greggailly commented on code in PR #42483:
URL: https://github.com/apache/superset/pull/42483#discussion_r3757285617
##########
superset-frontend/src/explore/components/DatasourcePanel/DatasourcePanelItem.tsx:
##########
@@ -175,9 +178,48 @@ const DatasourcePanelItem = ({
[labelIsTruncated],
);
- if (!item) return null;
+ // Folder headers double as a drag source: dragging the label picks up every
+ // column/metric in the folder (and its subfolders). Hooks must run on every
+ // row regardless of type, so compute the folder up front and disable the
+ // draggable for non-header rows / empty folders.
+ const isFolderHeader = item?.type === 'header';
+ const folder = item ? folderMap.get(item.folderId) : undefined;
+ const folderDragItems = useMemo(
+ () => (isFolderHeader && folder ? collectFolderDragItems(folder) : []),
+ [isFolderHeader, folder],
+ );
+ const folderDragIds = useMemo(
+ () => (isFolderHeader && folder ? collectFolderIds(folder) : []),
+ [isFolderHeader, folder],
+ );
+ const {
+ attributes: folderDragAttributes,
+ listeners: folderDragListeners,
+ setNodeRef: setFolderDragRef,
+ } = useDraggable({
+ // Keyed by the flattened row index so every row (header, item, divider…)
+ // gets a unique draggable id — a folder's header and its child rows would
+ // otherwise collide on the shared folder id.
+ id: `datasource-folder-row-${index}`,
+ data: {
+ type: DndItemType.Folder,
+ name: folder?.name,
+ items: folderDragItems,
Review Comment:
Refactored this and re-used the gates in DatasourcePanelDragOption
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]