Editors: Images and videos intermittently get deleted during upload or fail to persist after saving in the Rich Text Editor (RTE)
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=554669) </details> <!--IssueSummary end--> ## 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](/uploads/8d25f14a3541b7df234bd258da274ace/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 ![CleanShot 2025-07-09 at 13.11.25.mp4](/uploads/382f7a97d075e205bc76a12196e334da/CleanShot_2025-07-09_at_13.11.25.mp4) ![CleanShot 2025-07-09 at 13.11.25 \(1\).mp4](/uploads/bf5002b7158f2b14417134240342cbe3/CleanShot_2025-07-09_at_13.11.25__1_.mp4) ## 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
issue