Editors: Images and videos intermittently get deleted during upload or fail to persist after saving in the Rich Text Editor (RTE)

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem Summary

Users are experiencing intermittent failures when uploading images and videos in the Rich Text Editor. Uploaded media either fails to load, disappears after saving, or gets deleted mid-upload due to the editor returning focus to the upload position during active typing. The issue is not limited to tables - it occurs across issue descriptions, MR descriptions, and comments.

Affected Components

  • Rich Text Editor (Tiptap)
  • Image and video upload functionality
  • Editor focus and cursor management during async uploads
  • Save/persist mechanism for embedded media

Symptoms

  • Uploaded images show a broken/failed state (after saving) and require multiple retry attempts
  • Pasting a screenshot and immediately typing deletes the image, the editor re-focuses the cursor to the upload position mid-typing, and keypresses overwrite or remove the uploading media node
  • Images that finish uploading get removed by subsequent keypresses when the editor auto-refocuses to the upload area
  • Images disappear after saving even when the upload appeared to complete successfully
  • Issue occurs when saving before an upload reaches 100%
  • Intermittent failures with no consistent reproduction steps - sometimes works on retry without any changes

Observed Scenarios

  • Waiting a few seconds after pasting before continuing to type
  • Verifying the image has a valid /uploads/... path before proceeding
  • Retrying the save a second time without changes
  • Using Ctrl/Cmd+Z to attempt to restore a deleted image (not confirmed to work universally)

Screenshot 2025-07-04 at 6.40.16 PM.png

User Impact

Users are re-uploading the same assets multiple times, losing design feedback context in issues, and adopting manual workarounds just to reliably attach media. This is a consistent source of frustration.

Potential Root Causes to Investigate

  • Focus management: After a paste or drop event, the editor re-focuses the cursor at the upload node while the upload is still in progress, causing keypresses to delete the media
  • Race condition: Save operation executing before image upload metadata is fully processed
  • State management: Rich Text Editor state not properly synchronized with uploaded media
  • Backend timing: API calls for save happening before image references are properly stored
  • Tiptap limitation: Async upload state handling in Tiptap may not be guarding the upload node from user input during processing

Evidence

Suggested Improvements

  • Protect the upload node from deletion or overwrite while an upload is in progress
  • Implement upload completion verification before allowing save
  • Restore cursor position to where the user was typing rather than re-focusing on the upload node after paste
  • Add a clear uploading state indicator so users know not to save yet
  • Add retry logic for media persistence
  • Improve error reporting when media fails to save
Edited by Alex Fracazo