Skip to content

[BUG] Inline comment editor is destroyed mid-edit when the comment list refetches #138

Description

@martian56

Summary

The inline comment editor destroys its own TipTap instance when the comment list refetches while a comment is being edited, leaving a destroyed ProseMirror instance mounted.

Severity

High (editing UX) — code-confirmed; live repro requires a comment-list refetch to land while editing (e.g. a concurrent update/poll).

Affected code

  • ui/src/components/work-item/CommentEditor.tsx:67useEditor(...) is created with no recreation deps (returns a single instance).
  • ui/src/components/work-item/CommentEditor.tsx:90-100 — an effect keyed on [editor, initialHtml] whose cleanup calls editor.destroy() (line 98). When initialHtml changes while mounted, React runs the cleanup -> editor.destroy(), but the hook still returns the same now-destroyed instance.
  • Line 93 — setContent(initialHtml || '') uses the default emitUpdate: true, dirtying the doc on every seed.
  • The inline edit composer passes a live initialHtml={c.comment} from ui/src/pages/IssueDetailPage.tsx:746-747.

Impact

Mid-edit the editor can become non-functional (cannot type/format) and emits destroyed-instance console errors.

Suggested fix

Remove the manual editor.destroy() (the hook tears down on unmount). Only call setContent when initialHtml genuinely differs from editor.getHTML(), passing { emitUpdate: false }.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions