chore(react/collections/board): note not properly marked as dragged

This commit is contained in:
Elian Doran 2025-09-13 09:59:01 +03:00
parent ae5576f2a3
commit 7edfaad04e
No known key found for this signature in database
2 changed files with 11 additions and 3 deletions

View File

@ -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}
>

View File

@ -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");