mirror of
https://github.com/docmost/docmost.git
synced 2026-06-10 01:52:43 +08:00
refactor(bases): guard kanban column drag from menu clicks; polish hidden chips strip
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { Badge } from "@mantine/core";
|
||||
import { IconPlus } from "@tabler/icons-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
IBase,
|
||||
IBaseRow,
|
||||
@@ -36,6 +37,7 @@ export function BaseKanban({
|
||||
effectiveView,
|
||||
onCardClick,
|
||||
}: BaseKanbanProps) {
|
||||
const { t } = useTranslation();
|
||||
const groupByPropertyId = effectiveView?.config?.groupByPropertyId;
|
||||
const property = useMemo(
|
||||
() =>
|
||||
@@ -211,13 +213,13 @@ export function BaseKanban({
|
||||
return hiddenIds
|
||||
.map((id) =>
|
||||
id === NO_VALUE_CHOICE_ID
|
||||
? { id, name: "No value", color: null as string | null }
|
||||
? { id, name: t("No value"), color: null as string | null }
|
||||
: byId.get(id)
|
||||
? { id, name: byId.get(id)!.name, color: byId.get(id)!.color as string | null }
|
||||
: null,
|
||||
)
|
||||
.filter((c): c is { id: string; name: string; color: string | null } => c !== null);
|
||||
}, [hiddenIds, isGroupable, property]);
|
||||
}, [hiddenIds, isGroupable, property, t]);
|
||||
|
||||
if (!isGroupable) {
|
||||
return <KanbanEmptyState base={base} onPick={handlePickProperty} />;
|
||||
@@ -226,13 +228,13 @@ export function BaseKanban({
|
||||
return (
|
||||
<>
|
||||
{hiddenChoices.length > 0 && (
|
||||
<div style={{ padding: "6px 12px", display: "flex", gap: 6, flexWrap: "wrap" }}>
|
||||
<div className={classes.hiddenStrip}>
|
||||
{hiddenChoices.map((c) => (
|
||||
<Badge
|
||||
key={c.id}
|
||||
color={c.color ?? "gray"}
|
||||
variant="outline"
|
||||
style={{ cursor: "pointer" }}
|
||||
className={classes.hiddenChip}
|
||||
onClick={() => handleShowColumn(c.id)}
|
||||
rightSection={<IconPlus size={12} />}
|
||||
>
|
||||
|
||||
@@ -50,7 +50,7 @@ export function KanbanColumnHeader({
|
||||
</div>
|
||||
<Menu shadow="md" width={160} position="bottom-end">
|
||||
<Menu.Target>
|
||||
<ActionIcon variant="subtle" size="sm" color="gray">
|
||||
<ActionIcon variant="subtle" size="sm" color="gray" data-no-drag>
|
||||
<IconDots size={14} />
|
||||
</ActionIcon>
|
||||
</Menu.Target>
|
||||
|
||||
@@ -36,6 +36,16 @@ export function useKanbanColumnReorder({
|
||||
return combine(
|
||||
draggable({
|
||||
element: el,
|
||||
canDrag: ({ input }) => {
|
||||
// Don't start a drag when the user is interacting with a marked
|
||||
// "no-drag" subtree (e.g. the column header's menu trigger).
|
||||
const target = document.elementFromPoint(
|
||||
input.clientX,
|
||||
input.clientY,
|
||||
) as HTMLElement | null;
|
||||
if (target?.closest("[data-no-drag]")) return false;
|
||||
return true;
|
||||
},
|
||||
getInitialData: () => ({ type: "base-kanban-column", columnKey }),
|
||||
onDragStart: () => setIsDragging(true),
|
||||
onDrop: () => setIsDragging(false),
|
||||
|
||||
@@ -91,3 +91,14 @@
|
||||
font-size: var(--mantine-font-size-xs);
|
||||
color: var(--mantine-color-dimmed);
|
||||
}
|
||||
|
||||
.hiddenStrip {
|
||||
padding: 6px 12px;
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.hiddenChip {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user