mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
chore(react/collections/board): note not properly marked as dragged
This commit is contained in:
parent
ae5576f2a3
commit
7edfaad04e
@ -31,7 +31,7 @@ export default function Card({
|
|||||||
index: number,
|
index: number,
|
||||||
isDragging: boolean
|
isDragging: boolean
|
||||||
}) {
|
}) {
|
||||||
const { branchIdToEdit, setBranchIdToEdit } = useContext(BoardViewContext);
|
const { branchIdToEdit, setBranchIdToEdit, setDraggedCard } = useContext(BoardViewContext);
|
||||||
const isEditing = branch.branchId === branchIdToEdit;
|
const isEditing = branch.branchId === branchIdToEdit;
|
||||||
const colorClass = note.getColorClass() || '';
|
const colorClass = note.getColorClass() || '';
|
||||||
const editorRef = useRef<HTMLInputElement>(null);
|
const editorRef = useRef<HTMLInputElement>(null);
|
||||||
@ -41,9 +41,14 @@ export default function Card({
|
|||||||
const handleDragStart = useCallback((e: DragEvent) => {
|
const handleDragStart = useCallback((e: DragEvent) => {
|
||||||
e.dataTransfer!.effectAllowed = 'move';
|
e.dataTransfer!.effectAllowed = 'move';
|
||||||
const data: CardDragData = { noteId: note.noteId, branchId: branch.branchId, fromColumn: column, index };
|
const data: CardDragData = { noteId: note.noteId, branchId: branch.branchId, fromColumn: column, index };
|
||||||
|
setDraggedCard(data);
|
||||||
e.dataTransfer!.setData(CARD_CLIPBOARD_TYPE, JSON.stringify(data));
|
e.dataTransfer!.setData(CARD_CLIPBOARD_TYPE, JSON.stringify(data));
|
||||||
}, [note.noteId, branch.branchId, column, index]);
|
}, [note.noteId, branch.branchId, column, index]);
|
||||||
|
|
||||||
|
const handleDragEnd = useCallback((e: DragEvent) => {
|
||||||
|
setDraggedCard(null);
|
||||||
|
}, [setDraggedCard]);
|
||||||
|
|
||||||
const handleContextMenu = useCallback((e: ContextMenuEvent) => {
|
const handleContextMenu = useCallback((e: ContextMenuEvent) => {
|
||||||
openNoteContextMenu(api, e, note, branch.branchId, column);
|
openNoteContextMenu(api, e, note, branch.branchId, column);
|
||||||
}, [ api, note, branch, column ]);
|
}, [ api, note, branch, column ]);
|
||||||
@ -70,6 +75,7 @@ export default function Card({
|
|||||||
className={`board-note ${colorClass} ${isDragging ? 'dragging' : ''} ${isEditing ? "editing" : ""} ${isArchived ? "archived" : ""}`}
|
className={`board-note ${colorClass} ${isDragging ? 'dragging' : ''} ${isEditing ? "editing" : ""} ${isArchived ? "archived" : ""}`}
|
||||||
draggable="true"
|
draggable="true"
|
||||||
onDragStart={handleDragStart}
|
onDragStart={handleDragStart}
|
||||||
|
onDragEnd={handleDragEnd}
|
||||||
onContextMenu={handleContextMenu}
|
onContextMenu={handleContextMenu}
|
||||||
onClick={!isEditing ? handleOpen : undefined}
|
onClick={!isEditing ? handleOpen : undefined}
|
||||||
>
|
>
|
||||||
|
@ -34,10 +34,12 @@ interface BoardViewContextData {
|
|||||||
dropPosition: { column: string, index: number } | null;
|
dropPosition: { column: string, index: number } | null;
|
||||||
setDropPosition: (position: { column: string, index: number } | null) => void;
|
setDropPosition: (position: { column: string, index: number } | null) => void;
|
||||||
setDropTarget: (target: string | 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>) {
|
export default function BoardView({ note: parentNote, noteIds, viewConfig, saveConfig }: ViewModeProps<BoardViewData>) {
|
||||||
const [ statusAttribute ] = useNoteLabelWithDefault(parentNote, "board:groupBy", "status");
|
const [ statusAttribute ] = useNoteLabelWithDefault(parentNote, "board:groupBy", "status");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user