Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(editor): add dirty check and allow clearing description (#1132)
Naiyuan Qing3c46c5baa3a4
diff --git a/packages/views/editor/content-editor.tsx b/packages/views/editor/content-editor.tsxindex 53588cd908..80f5630aed 100644--- a/packages/views/editor/content-editor.tsx+++ b/packages/views/editor/content-editor.tsx@@ -112,6 +112,7 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(const onBlurRef = useRef(onBlur);const onUploadFileRef = useRef(onUploadFile);const prevContentRef = useRef(defaultValue);+ const lastEmittedRef = useRef<string | null>(null);// Keep refs in sync without recreating editoronUpdateRef.current = onUpdate;@@ -127,6 +128,9 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(// Explicit for clarity — the real perf win is useEditorState in BubbleMenu.shouldRerenderOnTransaction: false,editable,+ onCreate: ({ editor: ed }) => {+ lastEmittedRef.current = stripBlobUrls(ed.getMarkdown());+ },content: defaultValue ? preprocessMarkdown(defaultValue) : "",contentType: defaultValue ? "markdown" : undefined,extensions: createEditorExtensions({@@ -141,7 +145,10 @@ const ContentEditor = forwardRef<ContentEditorRef, ContentEditorProps>(if (!onUpdateRef.current) return;if (debounceRef.current) clearTimeout(debounceRef.current);debounceRef.current = setTimeout(() => {- onUpdateRef.current?.(stripBlobUrls(ed.getMarkdown()));+ const md = stripBlobUrls(ed.getMarkdown());+ if (md === lastEmittedRef.current) return;+ lastEmittedRef.current = md;+ onUpdateRef.current?.(md);}, debounceMs);},onBlur: () => {diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsxindex 01da32626f..625dae1e1b 100644--- a/packages/views/issues/components/issue-detail.test.tsx+++ b/packages/views/issues/components/issue-detail.test.tsx@@ -1,6 +1,6 @@import { forwardRef, useRef, useState, useImperativeHandle } from "react";import { describe, it, expect, vi, beforeEach } from "vitest";-import { render, screen, waitFor } from "@testing-library/react";+import { fireEvent, render, screen, waitFor } from "@testing-library/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import type { Issue, TimelineEntry } from "@multica/core/types";import { WorkspaceIdProvider } from "@multica/core/hooks";@@ -474,4 +474,22 @@ describe("IssueDetail (shared)", () => {expect(screen.getByText("I can help with this")).toBeInTheDocument();});++ it("sends empty description when editor is cleared", async () => {+ renderIssueDetail();++ await waitFor(() => {+ expect(screen.getByDisplayValue("Add JWT auth to the backend")).toBeInTheDocument();+ });++ const editor = screen.getByPlaceholderText("Add description...");+ fireEvent.change(editor, { target: { value: "" } });++ await waitFor(() => {+ expect(mockApiObj.updateIssue).toHaveBeenCalledWith(+ "issue-1",+ expect.objectContaining({ description: "" }),+ );+ });+ });});diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsxindex a95899f787..b0622a4e17 100644--- a/packages/views/issues/components/issue-detail.tsx+++ b/packages/views/issues/components/issue-detail.tsx@@ -1032,7 +1032,7 @@ export function IssueDetail({ issueId, onDelete, defaultSidebarOpen = true, layokey={id}defaultValue={issue.description || ""}placeholder="Add description..."- onUpdate={(md) => handleUpdateField({ description: md || undefined })}+ onUpdate={(md) => handleUpdateField({ description: md })}onUploadFile={handleDescriptionUpload}debounceMs={1500}/>