Welcome to Codidact Meta!
Codidact Meta is the "town hall" (meta-discussion site) for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.
Comments on Add a "Discard draft" button
Parent
Add a "Discard draft" button
If I want to discard a draft question/edit and start anew, I have to click Cancel then find my way back to the ask/edit page, or navigate back and refresh. I'd like to have a Discard draft button to do it directly.
Additionally, it's not super obvious that "Cancel" will discard a draft, so this would be good to add an explicit method.
More info
For reference, for a new question or answer, discarding means blanking all the fields. For an edit, it means reverting the fields to before starting the edit.
One pitfall I can imagine is that discarding an edit would require pulling the saved state, and if you naively pulled the current state of a post, it may have been edited in the meantime. Instead, it would be better to remember the state of the post from before starting the edit, which might be accomplished by tracking the revision number and pulling that, or saving the whole post content in the browser cache and repopulating it.
As a sort of alternative, "Cancel" could be changed to "Cancel and discard draft" where appropriate. This would at least make it explicit. Even hovertext would help, like "Cancel writing this post and discard any saved draft".
What I have in mind would not require refreshing the page, in which case it would be good to add the button to the answer box too, so that an answer draft can be discarded without having to refresh the page. But this is only a minor annoyance.
Previous feature requests:
- Allow discarding of drafts - Suggested "maybe a button" but mostly talked about Cancel.
- Reset button for drafts - Was effectively resolved by the above (Cancel).
Post
This won't help with your concern that the post may have been edited by someone else while you were drafting, but you can discard your draft without leaving the page using the red bin button at the right hand side of the editing toolbar above a post being edited:
Its hover text says "Delete saved draft". Ideally there would also be a way to see this text on touch screen devices which do not have the ability to hover.
This does not currently return the text you are editing to how it was before you started editing. It just deletes the saved draft from the server. Unless you switch off draft saving in your user preferences another draft will be saved once you continue typing.
It sounds like what you would like is either a separate button that restores the initial state of the post (which would be empty for a new post), or for this red bin button to do that also. If you want this to happen without a page reload, then perhaps the page should keep a copy of the initial state as you suggest.
It would be useful to hear from anyone who would object to the red bin button having this additional behaviour. Is there anyone who wants the red bin to only delete the draft from the server, and not revert the text to its initial state?

0 comment threads