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).
This commit is contained in:
Your Name
2026-02-15 19:30:58 +02:00
parent 07a4275e8c
commit 2a81849c8d
3 changed files with 18 additions and 23 deletions

View File

@@ -230,24 +230,6 @@ export function BoardView() {
[board, moveCard, moveColumn] [board, moveCard, moveColumn]
); );
if (!board) {
return (
<div className="flex h-full items-center justify-center text-pylon-text-secondary">
<span className="font-mono text-sm">Loading board...</span>
</div>
);
}
// 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 [announcement, setAnnouncement] = useState("");
const handleDragEndWithAnnouncement = useCallback( const handleDragEndWithAnnouncement = useCallback(
@@ -275,6 +257,24 @@ export function BoardView() {
[handleDragEnd, board] [handleDragEnd, board]
); );
if (!board) {
return (
<div className="flex h-full items-center justify-center text-pylon-text-secondary">
<span className="font-mono text-sm">Loading board...</span>
</div>
);
}
// 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 ( return (
<> <>
{/* Visually hidden live region for drag-and-drop announcements */} {/* Visually hidden live region for drag-and-drop announcements */}

View File

@@ -6,7 +6,6 @@ import type { Attachment } from "@/types/board";
interface AttachmentSectionProps { interface AttachmentSectionProps {
cardId: string; cardId: string;
attachments: Attachment[]; attachments: Attachment[];
attachmentMode: "link" | "copy";
} }
export function AttachmentSection({ export function AttachmentSection({

View File

@@ -24,9 +24,6 @@ export function CardDetailModal({ cardId, onClose }: CardDetailModalProps) {
cardId ? s.board?.cards[cardId] ?? null : null cardId ? s.board?.cards[cardId] ?? null : null
); );
const boardLabels = useBoardStore((s) => s.board?.labels ?? []); const boardLabels = useBoardStore((s) => s.board?.labels ?? []);
const attachmentMode = useBoardStore(
(s) => s.board?.settings.attachmentMode ?? "link"
);
const updateCard = useBoardStore((s) => s.updateCard); const updateCard = useBoardStore((s) => s.updateCard);
const open = cardId != null && card != null; const open = cardId != null && card != null;
@@ -82,7 +79,6 @@ export function CardDetailModal({ cardId, onClose }: CardDetailModalProps) {
<AttachmentSection <AttachmentSection
cardId={cardId} cardId={cardId}
attachments={card.attachments} attachments={card.attachments}
attachmentMode={attachmentMode}
/> />
</div> </div>
</div> </div>