diff --git a/web/components/issues/issue-layouts/properties/all-properties.tsx b/web/components/issues/issue-layouts/properties/all-properties.tsx index 4d851545e..390bea077 100644 --- a/web/components/issues/issue-layouts/properties/all-properties.tsx +++ b/web/components/issues/issue-layouts/properties/all-properties.tsx @@ -2,7 +2,7 @@ import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import { CalendarCheck2, CalendarClock, Layers, Link, Paperclip } from "lucide-react"; // hooks -import { useEventTracker, useEstimate, useLabel } from "hooks/store"; +import { useEventTracker, useEstimate, useLabel, useApplication } from "hooks/store"; // components import { IssuePropertyLabels } from "../properties/labels"; import { Tooltip } from "@plane/ui"; @@ -35,6 +35,9 @@ export const IssueProperties: React.FC = observer((props) => { // store hooks const { labelMap } = useLabel(); const { captureIssueEvent } = useEventTracker(); + const { + router: { workspaceSlug }, + } = useApplication(); // router const router = useRouter(); const { areEstimatesEnabledForCurrentProject } = useEstimate(); @@ -137,6 +140,15 @@ export const IssueProperties: React.FC = observer((props) => { }); }; + const redirectToIssueDetail = () => { + router.push({ + pathname: `/${workspaceSlug}/projects/${issue.project_id}/${issue.archived_at ? "archived-issues" : "issues"}/${ + issue.id + }`, + hash: "sub-issues", + }); + }; + if (!displayProperties) return null; const defaultLabelOptions = issue?.label_ids?.map((id) => labelMap[id]) || []; @@ -261,7 +273,10 @@ export const IssueProperties: React.FC = observer((props) => { shouldRenderProperty={!!issue?.sub_issues_count} > -
+
{issue.sub_issues_count}
diff --git a/web/components/issues/issue-layouts/spreadsheet/columns/sub-issue-column.tsx b/web/components/issues/issue-layouts/spreadsheet/columns/sub-issue-column.tsx index c0e41d2c0..20864eb96 100644 --- a/web/components/issues/issue-layouts/spreadsheet/columns/sub-issue-column.tsx +++ b/web/components/issues/issue-layouts/spreadsheet/columns/sub-issue-column.tsx @@ -1,6 +1,9 @@ import React from "react"; import { observer } from "mobx-react-lite"; +import { useRouter } from "next/router"; // hooks +import { useApplication } from "hooks/store"; +// types import { TIssue } from "@plane/types"; type Props = { @@ -9,9 +12,27 @@ type Props = { export const SpreadsheetSubIssueColumn: React.FC = observer((props: Props) => { const { issue } = props; + // router + const router = useRouter(); + // hooks + const { + router: { workspaceSlug }, + } = useApplication(); + + const redirectToIssueDetail = () => { + router.push({ + pathname: `/${workspaceSlug}/projects/${issue.project_id}/${issue.archived_at ? "archived-issues" : "issues"}/${ + issue.id + }`, + hash: "sub-issues", + }); + }; return ( -
+
{issue?.sub_issues_count} {issue?.sub_issues_count === 1 ? "sub-issue" : "sub-issues"}
); diff --git a/web/components/issues/sub-issues/root.tsx b/web/components/issues/sub-issues/root.tsx index d40a3f371..5e406116c 100644 --- a/web/components/issues/sub-issues/root.tsx +++ b/web/components/issues/sub-issues/root.tsx @@ -89,6 +89,25 @@ export const SubIssuesRoot: FC = observer((props) => { }, }); + const scrollToSubIssuesView = useCallback(() => { + if (router.asPath.split("#")[1] === "sub-issues") { + setTimeout(() => { + const subIssueDiv = document.getElementById(`sub-issues`); + if (subIssueDiv) + subIssueDiv.scrollIntoView({ + behavior: "smooth", + block: "start", + }); + }, 200); + } + }, [router.asPath]); + + useEffect(() => { + if (router.asPath) { + scrollToSubIssuesView(); + } + }, [router.asPath, scrollToSubIssuesView]); + const handleIssueCrudState = ( key: "create" | "existing" | "update" | "delete", _parentIssueId: string | null, @@ -287,7 +306,7 @@ export const SubIssuesRoot: FC = observer((props) => { if (!issue) return <>; return ( -
+
{!subIssues ? (
Loading...
) : (