Skip to content

Commit

Permalink
fix infinite loop for sub issues (makeplane#4550)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulramesha authored May 22, 2024
1 parent 9013497 commit fa332a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions web/components/issues/sub-issues/issue-list-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface ISubIssues {
workspaceSlug: string;
projectId: string;
parentIssueId: string;
rootIssueId: string;
spacingLeft: number;
disabled: boolean;
handleIssueCrudState: (
Expand All @@ -34,6 +35,7 @@ export const IssueListItem: React.FC<ISubIssues> = observer((props) => {
workspaceSlug,
projectId,
parentIssueId,
rootIssueId,
issueId,
spacingLeft = 10,
disabled,
Expand Down Expand Up @@ -70,6 +72,10 @@ export const IssueListItem: React.FC<ISubIssues> = 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 (
<div key={issueId}>
{issue && (
Expand All @@ -78,7 +84,8 @@ export const IssueListItem: React.FC<ISubIssues> = observer((props) => {
style={{ paddingLeft: `${spacingLeft}px` }}
>
<div className="h-[22px] w-[22px] flex-shrink-0">
{subIssueCount > 0 && (
{/* disable the chevron when current issue is also the root issue*/}
{subIssueCount > 0 && !isCurrentIssueRoot && (
<>
{subIssueHelpers.preview_loader.includes(issue.id) ? (
<div className="flex h-full w-full cursor-not-allowed items-center justify-center rounded-sm bg-custom-background-80 transition-all">
Expand Down Expand Up @@ -206,11 +213,13 @@ export const IssueListItem: React.FC<ISubIssues> = observer((props) => {
</div>
)}

{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 && (
<IssueList
workspaceSlug={workspaceSlug}
projectId={issue.project_id}
parentIssueId={issue.id}
rootIssueId={rootIssueId}
spacingLeft={spacingLeft + 22}
disabled={disabled}
handleIssueCrudState={handleIssueCrudState}
Expand Down
3 changes: 3 additions & 0 deletions web/components/issues/sub-issues/issues-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface IIssueList {
workspaceSlug: string;
projectId: string;
parentIssueId: string;
rootIssueId: string;
spacingLeft: number;
disabled: boolean;
handleIssueCrudState: (
Expand All @@ -27,6 +28,7 @@ export const IssueList: FC<IIssueList> = observer((props) => {
workspaceSlug,
projectId,
parentIssueId,
rootIssueId,
spacingLeft = 10,
disabled,
handleIssueCrudState,
Expand All @@ -50,6 +52,7 @@ export const IssueList: FC<IIssueList> = observer((props) => {
workspaceSlug={workspaceSlug}
projectId={projectId}
parentIssueId={parentIssueId}
rootIssueId={rootIssueId}
issueId={issueId}
spacingLeft={spacingLeft}
disabled={disabled}
Expand Down
1 change: 1 addition & 0 deletions web/components/issues/sub-issues/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = observer((props) => {
workspaceSlug={workspaceSlug}
projectId={projectId}
parentIssueId={parentIssueId}
rootIssueId={parentIssueId}
spacingLeft={10}
disabled={!disabled}
handleIssueCrudState={handleIssueCrudState}
Expand Down

0 comments on commit fa332a9

Please sign in to comment.