# Delete draft when escape is pressed with completely empty topic

**URL:** https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807
**Category:** UX
**Created:** [May 8, 2020, 10:51am UTC](https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807 "2020-05-08T10:51:54Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![aliceryhl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aliceryhl/32/179746_2.png) [@aliceryhl](https://meta.discourse.org/u/aliceryhl)
#### Post date: [May 8, 2020, 10:51am UTC](https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807/1 "2020-05-08T10:51:54Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 8, 2020, 10:04pm UTC](https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807/2 "2020-05-08T22:04:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 8, 2020, 10:13pm UTC](https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807/3 "2020-05-08T22:13:17Z")

</div>

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

> [@Draft is not being saved when creating a new PM](https://meta.discourse.org/t/draft-is-not-being-saved-when-creating-a-new-pm/149990/6):
>
> Indeed. Thanks for following up. That pushed me to dig deeper. It looks like it might have to do with timing. If you only enter “Hello” into the title line of the PM and stop, a draft will be saved white_check_markIf you only enter “Hello” into the textarea of the PM and stop, a draft will be saved white_check_markIf you enter “Hello” into the title line of the PM and then immediately enter “Hello” into the textarea, no draft is saved xIf you enter “Hello” into the textarea of t…

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:

> [@If title has been added, composer should only be minimised, not terminated](https://meta.discourse.org/t/if-title-has-been-added-composer-should-only-be-minimised-not-terminated/74591/10):
>
> This is done. Titles will be saved in a draft even if there’s no body.

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.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 11, 2020, 12:08am UTC](https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807/5 "2020-05-11T00:08:03Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![aliceryhl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aliceryhl/32/179746_2.png) [@aliceryhl](https://meta.discourse.org/u/aliceryhl)
#### Post date: [May 11, 2020, 7:40am UTC](https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807/6 "2020-05-11T07:40:11Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 11, 2020, 8:41am UTC](https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807/7 "2020-05-11T08:41:20Z")

</div>

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

I made this fix: [FIX: default to blank title on open · discourse/discourse@b180e6e · GitHub](https://github.com/discourse/discourse/commit/b180e6e737900b50939b088c7cb53fb5119354ef)

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

---

<div class="post-metadata">

### Author: ![aliceryhl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aliceryhl/32/179746_2.png) [@aliceryhl](https://meta.discourse.org/u/aliceryhl)
#### Post date: [May 11, 2020, 9:46am UTC](https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807/8 "2020-05-11T09:46:55Z")

</div>

Yep! That appears to work. Thank you!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 11, 2020, 10:38am UTC](https://meta.discourse.org/t/delete-draft-when-escape-is-pressed-with-completely-empty-topic/150807/9 "2020-05-11T10:38:13Z")

</div>


