From 2a81849c8df4b44b514f44bd7122fcc5e1c71548 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 15 Feb 2026 19:30:58 +0200 Subject: [PATCH] fix: move hooks before early return in BoardView, remove unused attachmentMode prop Fixed React hooks rules violation where useState and useCallback were called after a conditional return in BoardView. Removed unused attachmentMode prop from AttachmentSection (can be re-added when file dialog is wired up). --- src/components/board/BoardView.tsx | 36 +++++++++---------- .../card-detail/AttachmentSection.tsx | 1 - .../card-detail/CardDetailModal.tsx | 4 --- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/components/board/BoardView.tsx b/src/components/board/BoardView.tsx index 7c1e3f4..d9bc79f 100644 --- a/src/components/board/BoardView.tsx +++ b/src/components/board/BoardView.tsx @@ -230,24 +230,6 @@ export function BoardView() { [board, moveCard, moveColumn] ); - if (!board) { - return ( -
- Loading board... -
- ); - } - - // Get the active item for the drag overlay - const activeCard = - activeType === "card" && activeId ? board.cards[activeId] : null; - const activeColumn = - activeType === "column" && activeId - ? board.columns.find((c) => c.id === activeId) - : null; - - const columnIds = board.columns.map((c) => c.id); - const [announcement, setAnnouncement] = useState(""); const handleDragEndWithAnnouncement = useCallback( @@ -275,6 +257,24 @@ export function BoardView() { [handleDragEnd, board] ); + if (!board) { + return ( +
+ Loading board... +
+ ); + } + + // Get the active item for the drag overlay + const activeCard = + activeType === "card" && activeId ? board.cards[activeId] : null; + const activeColumn = + activeType === "column" && activeId + ? board.columns.find((c) => c.id === activeId) + : null; + + const columnIds = board.columns.map((c) => c.id); + return ( <> {/* Visually hidden live region for drag-and-drop announcements */} diff --git a/src/components/card-detail/AttachmentSection.tsx b/src/components/card-detail/AttachmentSection.tsx index d086351..fae56cd 100644 --- a/src/components/card-detail/AttachmentSection.tsx +++ b/src/components/card-detail/AttachmentSection.tsx @@ -6,7 +6,6 @@ import type { Attachment } from "@/types/board"; interface AttachmentSectionProps { cardId: string; attachments: Attachment[]; - attachmentMode: "link" | "copy"; } export function AttachmentSection({ diff --git a/src/components/card-detail/CardDetailModal.tsx b/src/components/card-detail/CardDetailModal.tsx index eeac037..10679da 100644 --- a/src/components/card-detail/CardDetailModal.tsx +++ b/src/components/card-detail/CardDetailModal.tsx @@ -24,9 +24,6 @@ export function CardDetailModal({ cardId, onClose }: CardDetailModalProps) { cardId ? s.board?.cards[cardId] ?? null : null ); const boardLabels = useBoardStore((s) => s.board?.labels ?? []); - const attachmentMode = useBoardStore( - (s) => s.board?.settings.attachmentMode ?? "link" - ); const updateCard = useBoardStore((s) => s.updateCard); const open = cardId != null && card != null; @@ -82,7 +79,6 @@ export function CardDetailModal({ cardId, onClose }: CardDetailModalProps) {