Delete draft when escape is pressed with completely empty topic

Due to repetitive strain injuries to my hand, I use my voice to navigate the forum, which in practice works by telling my computer what keys to press and using your keyboard shortcuts.

I will quite often press the c button accidentally, which opens the compose box for a new topic. If I was in the middle of typing other keys, this usually results in typing one or two letters in the topic title input field immediately. Even if I delete those characters again, pressing escape will not delete the draft, leaving an empty draft. (The draft is deleted properly if I didn’t type any characters)

Deleting the draft with my voice is rather difficult, so I will resort to using my mouse, which is not ideal. I have to tab over the create topic button to reach cancel, and I don’t want to risk clicking it.

Note that my word for pressing c is quite similar to the one for pressing k, which is a key I press rather often to navigate the forum.

13 Likes

Sure @riking what can we possibly do to address this?

1 Like

I believe this is connected to this other recent topic, also talking about the behavior when cancelling the composer after writing very little:

And this topic from 2017, where the behavior for “Titles will be saved in a draft even if there’s no body” was actually added:

So we have conflicting requests here, and need some way to determine whether the composer content is meaningful enough to:

  • save a draft vs wait for more words
  • minimize vs terminate composer

@tshenry initially thought that the min topic title length was consulted, but it is not. Sometimes people put a lot of effort into choosing tags. I don’t currently have a proposal for coherent and understandable behavior.

@sam, how much progress did you make on that other topic?


As a first pass, “save draft / minimize” and “don’t save / terminate” should probably be the only possible behaviors here. Unless we need to allow for “save draft / terminate” - likely only through a dialog box.

6 Likes

Aha Alice, I was getting a bit confused here cause we have quite thorough checks that ensure we never save drafts unless a minimal amount of letters are typed.

Turns out the issue here is less about drafts, it is more about our logic for minimizing the composer. The composer was “thinking” incorrectly that the title changed when, in fact, it did not.

I fixed this here:

https://github.com/discourse/discourse/commit/44712c5f9825eca6cb38ed5351f5fa33fc8d107e

Please update to latest and let me know how it feels. It should be live on meta in the next half hour or so.

10 Likes

It works on the front page now, but it doesn’t appear to work when inside a topic such as this one. Pressing “c escape” just leaves the composer at the bottom.

3 Likes

Weird, that only popped up in the production bundle … yikes

I made this fix: https://github.com/discourse/discourse/commit/b180e6e737900b50939b088c7cb53fb5119354ef

Let me know how you go … should be live on meta in about 30 mins or so.

9 Likes

Yep! That appears to work. Thank you!

4 Likes