"Esc" keyboard shortcut not working properly in edition mode

How to reproduce:

  1. Go to one of your post and click Edit to open the composer. Don’t type anything.
  2. Press the Esc key => as expected, the composer disappears completely (it isn’t minimized, because the post hasn’t been modified).
  3. Refresh the browser page => the composer comes back.

In step 2, if you click the Cancel button instead of pressing the Esc key, the behavior is correct, i.e. the composer doesn’t come back after browser refresh.

5 Likes

@jack2

I just did it, Yes it does exactly what you say. Not sure if it’s a bug or its suppose to do this actually.

3 Likes

I can’t repro this anymore, can you still repro this on try.discourse.org please ?

Yes, I’ve jus reproduced it on try.discourse.org.

Wait! It’s random! Sometimes it doesn’t occur.

Are you able to find a consistent repro? I have an idea for a fix, but I would prefer to have a consistent repro. Please.

1 Like

Here is a consistent repro:

  1. Go to one of your post and click Edit to open the composer. Don’t type anything.
  2. Wait a few seconds, until a check mark appears at the bottom right of the composer
  3. Press the Esc key => as expected, the composer disappears completely (it isn’t minimized, because the post hasn’t been modified).
  4. Refresh the browser page => the composer comes back.
2 Likes

Nice! Ok so my fix idea will probably work, thanks hugely appreciated :heart:

3 Likes

This was way more trickier than expected, I think this should fix it:

https://github.com/discourse/discourse/pull/9305

I have asked multiple reviews and it might take time to merge, thanks again for the detailed repro :+1:

5 Likes

Quick update, I just closed the PR. The fix was working, but we are going to try to fix it at a higher level.

Might take some time :slight_smile:

4 Likes

I did this fix:

https://github.com/discourse/discourse/commit/a34711c23a58c991e44af2ff5e62f618107b244d

This file is mega tricky @eviltrout … can not wait till we have support for async cause a big pile of methods sometimes return a promise and sometimes return an object making it very hard to reason about things.

For now I introduced a few promises and bypasses so we do not save a draft right away after you click the edit button. This was also driving @supermathie crazy cause it made it really complicated and annoying to copy text from N replies into the OP.

7 Likes

This explains a lot of frustration I was having, :clap:

4 Likes

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.