Skip to content

When localStorage draft exists for comment reply, show it on load

What does this MR do and why?

When a user has a comment draft saved in localstorage, we do not indicate that on page load at all; the user can only see their comment draft by clicking reply and seeing the draft populated into the markdown editor.

This MR changes the noteable_discussion component's behavior such that it exposes the markdown editor with the user's comment draft on page load if there is a saved draft for the comment in localstorage.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Scenario Before After
User has draft of top level comment and reloads page image image
(no change)
User has draft of reply comment and reloads page image
(reply draft is not shown, top level comment is collapsed)
image

How to set up and validate locally

  1. Check out this branch locally
  2. Visit an issue or MR
  3. Start tying a new top-level comment
  4. Refresh the page
  5. You will see that your draft remains and the edit state is exposed (this is the behavior already on prod for top-level comment drafts)
  6. If there are any existing top level comments, start writing a reply to one. Otherwise, submit your comment draft and then start writing a reply to it.
  7. Refresh the page before submitting your reply comment
  8. You will see that when you refresh the page, your reply comment draft is visible in the exposed edit state. Autofocus will not move focus to the saved reply draft. The behavior for this threaded reply draft now matches the behavior for top-level comment drafts.

Related to #388684

Edited by Chad Lavimoniere

Merge request reports