From 52d8d6e7ce57aabf552959158c920ffd1c5d875b Mon Sep 17 00:00:00 2001 From: rahulramesha <71900764+rahulramesha@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:03:49 +0530 Subject: [PATCH] [WEB-1517] chore: remove drag handle from list drag block (#4698) * remove drag handle from list drag block * align list group header with list item * rearrange chevron for list subissues and rearrange spaces * adding default draggable property to control link * remove unnecessary dependencies for useEffect --- packages/ui/src/control-link/control-link.tsx | 13 ++++- .../issues/issue-layouts/list/block.tsx | 52 ++++++++++--------- .../list/headers/group-by-card.tsx | 4 +- .../issues/issue-layouts/list/list-group.tsx | 2 +- .../list/quick-add-issue-form.tsx | 2 +- 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/packages/ui/src/control-link/control-link.tsx b/packages/ui/src/control-link/control-link.tsx index df1958476..83f3157cc 100644 --- a/packages/ui/src/control-link/control-link.tsx +++ b/packages/ui/src/control-link/control-link.tsx @@ -7,10 +7,11 @@ export type TControlLink = React.AnchorHTMLAttributes & { target?: string; disabled?: boolean; className?: string; + draggable?: boolean; }; export const ControlLink = React.forwardRef((props, ref) => { - const { href, onClick, children, target = "_self", disabled = false, className, ...rest } = props; + const { href, onClick, children, target = "_self", disabled = false, className, draggable = false, ...rest } = props; const LEFT_CLICK_EVENT_CODE = 0; const handleOnClick = (event: React.MouseEvent) => { @@ -33,7 +34,15 @@ export const ControlLink = React.forwardRef((pr if (disabled) return <>{children}; return ( - + {children} ); diff --git a/web/components/issues/issue-layouts/list/block.tsx b/web/components/issues/issue-layouts/list/block.tsx index 56d88a730..358c72189 100644 --- a/web/components/issues/issue-layouts/list/block.tsx +++ b/web/components/issues/issue-layouts/list/block.tsx @@ -6,7 +6,7 @@ import { ChevronRight } from "lucide-react"; // types import { TIssue, IIssueDisplayProperties, TIssueMap } from "@plane/types"; // ui -import { Spinner, Tooltip, ControlLink, DragHandle } from "@plane/ui"; +import { Spinner, Tooltip, ControlLink, setToast, TOAST_TYPE } from "@plane/ui"; // components import { MultipleSelectEntityAction } from "@/components/core"; import { IssueProperties } from "@/components/issues/issue-layouts/properties"; @@ -57,7 +57,6 @@ export const IssueBlock = observer((props: IssueBlockProps) => { } = props; // ref const issueRef = useRef(null); - const dragHandleRef = useRef(null); // hooks const { workspaceSlug, projectId } = useAppRouter(); const { getProjectIdentifierById } = useProject(); @@ -78,14 +77,12 @@ export const IssueBlock = observer((props: IssueBlockProps) => { useEffect(() => { const element = issueRef.current; - const dragHandleElement = dragHandleRef.current; - if (!element || !dragHandleElement) return; + if (!element) return; return combine( draggable({ element, - dragHandle: dragHandleElement, canDrag: () => canDrag, getInitialData: () => ({ id: issueId, type: "ISSUE", groupId }), onDragStart: () => { @@ -96,7 +93,7 @@ export const IssueBlock = observer((props: IssueBlockProps) => { }, }) ); - }, [issueRef?.current, canDrag, issueId, groupId, dragHandleRef?.current, setIsCurrentBlockDragging]); + }, [canDrag, issueId, groupId, setIsCurrentBlockDragging]); if (!issue) return null; @@ -135,20 +132,19 @@ export const IssueBlock = observer((props: IssueBlockProps) => { "bg-custom-background-80": isCurrentBlockDragging, } )} + onDragStart={() => { + if (!canDrag) { + setToast({ + type: TOAST_TYPE.WARNING, + title: "Cannot move issue", + message: "Drag and drop is disabled for the current grouping", + }); + } + }} >
-
-
- {/* drag handle */} -
- -
+
+
{/* select checkbox */} {projectId && canEditIssueProperties && ( {
)} + {displayProperties && displayProperties?.key && ( +
+ {projectIdentifier}-{issue.sequence_id} +
+ )} + {/* sub-issues chevron */} -
+
{subIssuesCount > 0 && ( )}
- {displayProperties && displayProperties?.key && ( -
- {projectIdentifier}-{issue.sequence_id} -
- )} {issue?.tempId !== undefined && (
@@ -206,7 +203,12 @@ export const IssueBlock = observer((props: IssueBlockProps) => {
{issue?.is_draft ? ( - +

{issue.name}

) : ( diff --git a/web/components/issues/issue-layouts/list/headers/group-by-card.tsx b/web/components/issues/issue-layouts/list/headers/group-by-card.tsx index feb99a8a5..cfda91613 100644 --- a/web/components/issues/issue-layouts/list/headers/group-by-card.tsx +++ b/web/components/issues/issue-layouts/list/headers/group-by-card.tsx @@ -83,7 +83,7 @@ export const HeaderGroupByCard = observer((props: IHeaderGroupByCard) => { return ( <> -
+
{canSelectIssues && (
{ />
)} -
+
{icon ?? }
diff --git a/web/components/issues/issue-layouts/list/list-group.tsx b/web/components/issues/issue-layouts/list/list-group.tsx index 04457327e..64cbf807b 100644 --- a/web/components/issues/issue-layouts/list/list-group.tsx +++ b/web/components/issues/issue-layouts/list/list-group.tsx @@ -193,7 +193,7 @@ export const ListGroup = observer((props: Props) => { "border-custom-error-200": isDraggingOverColumn && !!group.isDropDisabled, })} > -
+
= observer((props
) : (
setIsOpen(true)} >