fix: Icon missing in ghost when dragging collection

This commit is contained in:
Tom Moor committed 2024-07-10 22:45:10 -04:00
1 parent c600148f4b
commit 67c0335099
2 files changed
+4 -4

No files matched your search

@@ -143,6 +143,8 @@ function InnerDocumentLink(
const isMoving = documents.movingDocumentId === node.id;
const manualSort = collection?.sort.field === "index";
const can = policies.abilities(node.id);
const icon = document?.icon || node.icon || node.emoji;
const color = document?.color || node.color;
// Draggable
const [{ isDragging }, drag, preview] = useDrag({
@@ -150,6 +152,7 @@ function InnerDocumentLink(
item: () => ({
...node,
depth,
icon: icon ? <Icon value={icon} color={color} /> : undefined,
active: isActiveDocument,
collectionId: collection?.id || "",
}),
@@ -283,8 +286,6 @@ function InnerDocumentLink(
const title =
(activeDocument?.id === node.id ? activeDocument.title : node.title) ||
t("Untitled");
const icon = document?.icon || node.icon || node.emoji;
const color = document?.color || node.color;
const isExpanded = expanded && !isDragging;
const hasChildren = nodeChildren.length > 0;
@@ -2,7 +2,6 @@ import * as React from "react";
import { useDragLayer, XYCoord } from "react-dnd";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import Icon from "~/components/Icon";
import useStores from "~/hooks/useStores";
import SidebarLink from "./SidebarLink";
@@ -62,7 +61,7 @@ const DragPlaceholder = () => {
<div style={layerStyles}>
<div style={getItemStyles(initialOffset, currentOffset, ui.sidebarWidth)}>
<GhostLink
icon={<Icon value={item.icon ?? item.emoji} color={item.color} />}
icon={item.icon}
label={item.title || t("Untitled")}
isDraft={item.isDraft}
depth={item.depth}