Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(react/collections/board): note not properly marked as dragged
Elian Doran7edfaad04ede
diff --git a/apps/client/src/widgets/collections/board/card.tsx b/apps/client/src/widgets/collections/board/card.tsxindex bd377f2ec7..342f781ad9 100644--- a/apps/client/src/widgets/collections/board/card.tsx+++ b/apps/client/src/widgets/collections/board/card.tsx@@ -31,7 +31,7 @@ export default function Card({index: number,isDragging: boolean}) {- const { branchIdToEdit, setBranchIdToEdit } = useContext(BoardViewContext);+ const { branchIdToEdit, setBranchIdToEdit, setDraggedCard } = useContext(BoardViewContext);const isEditing = branch.branchId === branchIdToEdit;const colorClass = note.getColorClass() || '';const editorRef = useRef<HTMLInputElement>(null);@@ -41,9 +41,14 @@ export default function Card({const handleDragStart = useCallback((e: DragEvent) => {e.dataTransfer!.effectAllowed = 'move';const data: CardDragData = { noteId: note.noteId, branchId: branch.branchId, fromColumn: column, index };+ setDraggedCard(data);e.dataTransfer!.setData(CARD_CLIPBOARD_TYPE, JSON.stringify(data));}, [note.noteId, branch.branchId, column, index]);+ const handleDragEnd = useCallback((e: DragEvent) => {+ setDraggedCard(null);+ }, [setDraggedCard]);+const handleContextMenu = useCallback((e: ContextMenuEvent) => {openNoteContextMenu(api, e, note, branch.branchId, column);}, [ api, note, branch, column ]);@@ -70,6 +75,7 @@ export default function Card({className={`board-note ${colorClass} ${isDragging ? 'dragging' : ''} ${isEditing ? "editing" : ""} ${isArchived ? "archived" : ""}`}draggable="true"onDragStart={handleDragStart}+ onDragEnd={handleDragEnd}onContextMenu={handleContextMenu}onClick={!isEditing ? handleOpen : undefined}>diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsxindex a71a117a39..8b95da30b2 100644--- a/apps/client/src/widgets/collections/board/index.tsx+++ b/apps/client/src/widgets/collections/board/index.tsx@@ -34,10 +34,12 @@ interface BoardViewContextData {dropPosition: { column: string, index: number } | null;setDropPosition: (position: { column: string, index: number } | null) => void;setDropTarget: (target: string | null) => void,- dropTarget: string | null+ dropTarget: string | null;+ draggedCard: { noteId: string, branchId: string, fromColumn: string, index: number } | null;+ setDraggedCard: Dispatch<StateUpdater<{ noteId: string; branchId: string; fromColumn: string; index: number; } | null>>;}-export const BoardViewContext = createContext<BoardViewContextData>({});+export const BoardViewContext = createContext<BoardViewContextData | undefined>(undefined);export default function BoardView({ note: parentNote, noteIds, viewConfig, saveConfig }: ViewModeProps<BoardViewData>) {const [ statusAttribute ] = useNoteLabelWithDefault(parentNote, "board:groupBy", "status");