From fa332a9ba7d298363de34451115a701c84aad8f4 Mon Sep 17 00:00:00 2001 From: rahulramesha <71900764+rahulramesha@users.noreply.github.com> Date: Wed, 22 May 2024 15:36:11 +0530 Subject: [PATCH] fix infinite loop for sub issues (#4550) --- .../issues/sub-issues/issue-list-item.tsx | 13 +++++++++++-- web/components/issues/sub-issues/issues-list.tsx | 3 +++ web/components/issues/sub-issues/root.tsx | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/web/components/issues/sub-issues/issue-list-item.tsx b/web/components/issues/sub-issues/issue-list-item.tsx index 111d5d6c6..a3c3e9946 100644 --- a/web/components/issues/sub-issues/issue-list-item.tsx +++ b/web/components/issues/sub-issues/issue-list-item.tsx @@ -18,6 +18,7 @@ export interface ISubIssues { workspaceSlug: string; projectId: string; parentIssueId: string; + rootIssueId: string; spacingLeft: number; disabled: boolean; handleIssueCrudState: ( @@ -34,6 +35,7 @@ export const IssueListItem: React.FC = observer((props) => { workspaceSlug, projectId, parentIssueId, + rootIssueId, issueId, spacingLeft = 10, disabled, @@ -70,6 +72,10 @@ export const IssueListItem: React.FC = observer((props) => { setPeekIssue({ workspaceSlug, projectId: issue.project_id, issueId: issue.id }); if (!issue) return <>; + + // check if current issue is the root issue + const isCurrentIssueRoot = issueId === rootIssueId; + return (
{issue && ( @@ -78,7 +84,8 @@ export const IssueListItem: React.FC = observer((props) => { style={{ paddingLeft: `${spacingLeft}px` }} >
- {subIssueCount > 0 && ( + {/* disable the chevron when current issue is also the root issue*/} + {subIssueCount > 0 && !isCurrentIssueRoot && ( <> {subIssueHelpers.preview_loader.includes(issue.id) ? (
@@ -206,11 +213,13 @@ export const IssueListItem: React.FC = observer((props) => {
)} - {subIssueHelpers.issue_visibility.includes(issueId) && subIssueCount > 0 && ( + {/* should not expand the current issue if it is also the root issue*/} + {subIssueHelpers.issue_visibility.includes(issueId) && subIssueCount > 0 && !isCurrentIssueRoot && ( = observer((props) => { workspaceSlug, projectId, parentIssueId, + rootIssueId, spacingLeft = 10, disabled, handleIssueCrudState, @@ -50,6 +52,7 @@ export const IssueList: FC = observer((props) => { workspaceSlug={workspaceSlug} projectId={projectId} parentIssueId={parentIssueId} + rootIssueId={rootIssueId} issueId={issueId} spacingLeft={spacingLeft} disabled={disabled} diff --git a/web/components/issues/sub-issues/root.tsx b/web/components/issues/sub-issues/root.tsx index 4827e1277..a88434e3b 100644 --- a/web/components/issues/sub-issues/root.tsx +++ b/web/components/issues/sub-issues/root.tsx @@ -399,6 +399,7 @@ export const SubIssuesRoot: FC = observer((props) => { workspaceSlug={workspaceSlug} projectId={projectId} parentIssueId={parentIssueId} + rootIssueId={parentIssueId} spacingLeft={10} disabled={!disabled} handleIssueCrudState={handleIssueCrudState}