fix(web): close kanban preview when opening the edit dialog (#868)
* 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 <agent@kandev.dev>
This commit is contained in:
@@ -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 <div className="h-dvh w-full bg-background" />;
|
||||
|
||||
@@ -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?.();
|
||||
|
||||
@@ -316,7 +316,11 @@ function FloatingPreviewLayout({
|
||||
return (
|
||||
<>
|
||||
<div className="flex-1 overflow-hidden" style={{ width: `${kanbanWidth}px` }}>
|
||||
<KanbanBoard onPreviewTask={onPreviewTask} onOpenTask={onNavigateToTask} />
|
||||
<KanbanBoard
|
||||
onPreviewTask={onPreviewTask}
|
||||
onOpenTask={onNavigateToTask}
|
||||
onBeforeEdit={onClose}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="fixed inset-0 bg-black/30 z-30"
|
||||
@@ -362,7 +366,11 @@ function InlinePreviewLayout({
|
||||
return (
|
||||
<div className="flex-1 flex overflow-hidden">
|
||||
<div className="overflow-hidden" style={{ width: `${kanbanWidth}px` }}>
|
||||
<KanbanBoard onPreviewTask={onPreviewTask} onOpenTask={onNavigateToTask} />
|
||||
<KanbanBoard
|
||||
onPreviewTask={onPreviewTask}
|
||||
onOpenTask={onNavigateToTask}
|
||||
onBeforeEdit={onClose}
|
||||
/>
|
||||
</div>
|
||||
{isOpen && (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user