From 88947c7ca92c74b40b33a37e32d4f2b9ec99c9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Salavisa?= Date: Mon, 11 May 2026 13:33:18 +0100 Subject: [PATCH] fix(web): close kanban preview when opening the edit dialog (#868) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(web): close kanban preview when opening the edit dialog The dialog overlay used to mask the preview panel behind a backdrop blur; once the blur was dropped in #761, the preview kept rendering alongside the dialog and the layout looked broken — especially noticeable when editing a backlog task whose preview was already pinned open. * fix(web): stop card-click from firing when using kanban dropdown React's synthetic events bubble through the React tree even from a portal, so clicking Archive or Delete in the kanban card's dropdown propagated up to the card's onClick and navigated to the task page instead of opening the confirm dialog. Stop click propagation on each menu item and stabilize the new edit-handler's useCallback dep (PR review feedback). * fix(web): condense kanban handler comments to one line --------- Co-authored-by: Kandev Agent --- apps/web/components/kanban-board.tsx | 17 +++++++++++++++-- apps/web/components/kanban-card-menu-items.tsx | 4 ++++ apps/web/components/kanban-with-preview.tsx | 12 ++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/apps/web/components/kanban-board.tsx b/apps/web/components/kanban-board.tsx index fc7d2ae317..ff71c66fa9 100644 --- a/apps/web/components/kanban-board.tsx +++ b/apps/web/components/kanban-board.tsx @@ -136,6 +136,8 @@ function useKanbanBoardStore() { interface KanbanBoardProps { onPreviewTask?: (task: Task) => void; onOpenTask?: (task: Task) => void; + /** Fired before the edit dialog opens so the preview panel can close itself. */ + onBeforeEdit?: () => void; } function useKanbanBoardHooks( @@ -227,6 +229,7 @@ function useMultiSelectDerived( function useKanbanBoardSetup( onPreviewTask: KanbanBoardProps["onPreviewTask"], onOpenTask: KanbanBoardProps["onOpenTask"], + onBeforeEdit: KanbanBoardProps["onBeforeEdit"], ) { const router = useRouter(); const { isMobile } = useResponsiveBreakpoint(); @@ -251,6 +254,15 @@ function useKanbanBoardSetup( onPreviewTask, onOpenTask, }); + // Close preview before the edit dialog opens; destructure for stable useCallback dep. + const { handleEdit } = hooks; + const handleEditWithCleanup = useCallback( + (task: Task) => { + onBeforeEdit?.(); + handleEdit(task); + }, + [onBeforeEdit, handleEdit], + ); const multiSelect = useTaskMultiSelect(kanban.workflowId); const { isMultiSelectMode, toggleSelect } = multiSelect; @@ -299,6 +311,7 @@ function useKanbanBoardSetup( searchQuery, setSearchQuery, ...hooks, + handleEdit: handleEditWithCleanup, ...automation, handleOpenTask, handleCardClick: handleCardClickOrSelect, @@ -310,8 +323,8 @@ function useKanbanBoardSetup( }; } -export function KanbanBoard({ onPreviewTask, onOpenTask }: KanbanBoardProps = {}) { - const s = useKanbanBoardSetup(onPreviewTask, onOpenTask); +export function KanbanBoard({ onPreviewTask, onOpenTask, onBeforeEdit }: KanbanBoardProps = {}) { + const s = useKanbanBoardSetup(onPreviewTask, onOpenTask, onBeforeEdit); if (!s.isMounted) { return
; diff --git a/apps/web/components/kanban-card-menu-items.tsx b/apps/web/components/kanban-card-menu-items.tsx index 1c42863264..c3da448b79 100644 --- a/apps/web/components/kanban-card-menu-items.tsx +++ b/apps/web/components/kanban-card-menu-items.tsx @@ -360,6 +360,8 @@ function ContextEntry({ entry }: { entry: KanbanCardMenuEntry }) { data-testid={entry.testId} disabled={entry.disabled} className={entry.destructive ? "text-destructive focus:text-destructive" : undefined} + // React events bubble through the React tree even from a portal — stop here so the card's onClick doesn't navigate. + onClick={(event) => event.stopPropagation()} onSelect={() => { if (!entry.disabled) entry.onSelect?.(); }} @@ -402,6 +404,8 @@ function DropdownEntry({ entry }: { entry: KanbanCardMenuEntry }) { data-testid={entry.testId} disabled={entry.disabled} className={entry.destructive ? "text-destructive focus:text-destructive" : undefined} + // React events bubble through the React tree even from a portal — stop here so the card's onClick doesn't navigate. + onClick={(event) => event.stopPropagation()} onSelect={(event) => { event.stopPropagation(); if (!entry.disabled) entry.onSelect?.(); diff --git a/apps/web/components/kanban-with-preview.tsx b/apps/web/components/kanban-with-preview.tsx index 6d723add32..740a785114 100644 --- a/apps/web/components/kanban-with-preview.tsx +++ b/apps/web/components/kanban-with-preview.tsx @@ -316,7 +316,11 @@ function FloatingPreviewLayout({ return ( <>
- +
- +
{isOpen && (