As part of https://gitlab.com/gitlab-org/gitlab-ee/issues/1984, we are leveraging an already existing feature: Content is saved in comment textboxes in local storage. In that issue, there are designs to explicitly show this to the user.
The benefit is that we are able to do some pre-work before the main feature.
Also, we get consistent behavior and common code across Gitlab.
For comment boxes in issues, merge requests (non-diff and diff) discussions, and commit (non-diff and diff) discussions, we should implement the same design.
Currently, in the existing implementation, there is no status that shows something is "being saved". We should have that.
Currently, in the existing implementation, sometimes there is a Cancel button. Sometimes it says Discard draft. We should have a consistent design.
Currently in the existing implementation, there is to nothing to explicit to indicate something is already "saved" to local storage. I think we should have that if this design will be brought to https://gitlab.com/gitlab-org/gitlab-ee/issues/1984.
Designs
Current discussion is unresolved
Viewing the discussion
If you click the text area
If you click the button
Notice that the checkbox label only allows you to resolve the discussion. You can either resolve it or leave it unresolved. There's no confusion.
If you click the text area to start the draft, you haven't made any "draft changes" yet, so the save button is disabled until you either enter text or check the checkbox.
If you click the button to start the draft, you've made a change by definition, so the save button is already enabled.
If you click discard, any text changes and your checkbox selection is thrown away and you go back to the first image.
Also note that if you are entering first comment (i.e. creating a brand new discussion) with your draft comment, you would get the second image above. So this is slightly different from existing non-draft mode because you can comment and resolve all in one action. That's okay I think.
Current discussion is resolved
Viewing the discussion
If you click the text area
If you click the button
Everything here is just reversed. But everything is consistent with the previous case.
View saved draft
Per discussion above (in particular, https://gitlab.com/gitlab-org/gitlab-ce/issues/40462#note_51307188), I think it's easiest if you can only ever have one saved draft per discussion. So again, if this is the case, the resolve/unresolve direction is already well-defined. (Again, we can ignore real-time changes and ignore if the discussion state changes since the draft was saved, for now.)