Skip to content

Commit

Permalink
fix: updated issue description rendering when we switch between two i…
Browse files Browse the repository at this point in the history
…ssues via sub-issue (#4143)
  • Loading branch information
gurusainath authored Apr 8, 2024
1 parent c843a17 commit 03df410
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions web/components/issues/issue-detail/main-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
const { workspaceSlug, projectId, issueId, issueOperations, is_editable } = props;
// states
const [isSubmitting, setIsSubmitting] = useState<"submitting" | "submitted" | "saved">("saved");
const [issueDescription, setIssueDescription] = useState<string | undefined>(undefined);
// hooks
const { currentUser } = useUser();
const { projectStates } = useProjectState();
Expand All @@ -52,12 +53,16 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {

const currentIssueState = projectStates?.find((s) => s.id === issue.state_id);

const issueDescription =
issue.description_html !== undefined || issue.description_html !== null
? issue.description_html != ""
? issue.description_html
: "<p></p>"
: undefined;
useEffect(() => {
setIssueDescription(
issue.description_html !== undefined || issue.description_html !== null
? issue.description_html != ""
? issue.description_html
: "<p></p>"
: undefined
);
return () => setIssueDescription(undefined);
}, [issue.description_html]);

return (
<>
Expand Down Expand Up @@ -94,16 +99,18 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
value={issue.name}
/>

<IssueDescriptionInput
workspaceSlug={workspaceSlug}
projectId={issue.project_id}
issueId={issue.id}
value={issueDescription}
initialValue={issueDescription}
disabled={!is_editable}
issueOperations={issueOperations}
setIsSubmitting={(value) => setIsSubmitting(value)}
/>
{issue?.description_html === issueDescription && (
<IssueDescriptionInput
workspaceSlug={workspaceSlug}
projectId={issue.project_id}
issueId={issue.id}
value={issueDescription}
initialValue={issueDescription}
disabled={!is_editable}
issueOperations={issueOperations}
setIsSubmitting={(value) => setIsSubmitting(value)}
/>
)}

{currentUser && (
<IssueReaction
Expand Down

0 comments on commit 03df410

Please sign in to comment.