Skip to content

Comment editor clears typed text before the submit resolves (data loss on failure) #315

Description

@cavidelizade

What happens

Posting a work-item comment clears the editor before the request resolves, so a failed submit silently loses the typed text.

apps/web/src/components/work-item/CommentEditor.tsx:108-115:

const handleSubmit = () => {
  if (isSubmitting) return;
  const html = editor.getHTML().trim();
  if (html === '<p></p>' || html === '') return;
  void onSubmit(html, access);      // fire-and-forget
  editor.commands.clearContent();   // wipes immediately
  setIsEmpty(true);
};

onSubmit isn't awaited, and there's no error handling. If it rejects (offline, 5xx, or the EXTERNAL-comment permission error) the comment is already gone and the user sees nothing.

Repro

  1. Open a work item, type a comment.
  2. Kill the network (or trigger a 4xx/5xx).
  3. Press submit → the editor empties, no error, comment lost.

Fix

await onSubmit(...) in a try/catch; only clearContent() on success and surface the failure — the same way DescriptionEditor.tsx already tracks a save state.

I'll open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions