Keyboard new topic incorrectly recalls post, not topic, draft


(TheLoneCuber) #1

When I create topics via the ‘c’ keyboard shortcut, all the text from the last-created topic appears in the new topic tray. So the title input is filled with the last-create title, the category is set to the last-used category, and the topic field contains the entire text from the previous topic. Is this known or expected to behaviour?


(Jeff Atwood) #2

No repro.

  1. Went to try.discourse.org
  2. Logged in
  3. Pressed “c” to create a topic
  4. entered title, category, and body using the keyboard
  5. pressed ctrl+enter to submit
  6. topic created OK
  7. Pressed “c” to create another topic… no pre-filled content.

(Mittineague) #3

I didn’t replicate here at meta using latest Firefox

@TheLoneCuber did you have an unposted Draft? Does ot happen only with a specific browser?


(TheLoneCuber) #4

I’m using the latest Chrome for Mac (Version 38.0.2125.122) and it happens in multiple instances of Discourse (all are Discourse 1.1.0.beta8).

Here’s a quick screencast of it in action, using the exact steps as @codinghorror outlines above…

http://quick.as/1losgjg


(Jeff Atwood) #5

Does it happen on try.discourse.org? Are you following my steps exactly or deviating in some way (mouse vs. keyboard)?


(TheLoneCuber) #6

@codinghorror Yep it happens on try.discourse.org also, using exactly the steps outlined above.

@Mittineague re: draft posts - do they get saved somewhere that’s accessible for later use (and I might not know I have one drafted), or can they only ever live in the new post tray that pops up from the bottom of the page?


(Jeff Atwood) #7

Can you try in a different browser, or in your browser’s incognito mode?


(TheLoneCuber) #8

Update

Using the keyboard to “cancel” the new topic (which was pre-populated with old text) seems to have fix the problem on all 3 instances of Discourse it was happening (2 of mine + try.discourse.org). I keyboard tabbed to “Cancel” and now new topics are generating without old content.


(TheLoneCuber) #9

Don’t close this topic yet @codinghorror. The gremlin is back.


(cpradio) #10

This would happen even if you use the Create Topic button. When you are across instances, each instance has a local idea of your current draft. When you complete it in one instance, it still exist in the other two and may pop it up until all the tabs/windows are synchronized (which works best by closing them and re-opening them).

I’ve seen this in the past and it isn’t directly related to the ‘c’ shortcut, the shortcut just makes it easier to get to Create a Topic from anywhere.


(Jeff Atwood) #11

I don’t think you have an issue @TheLoneCuber, I think you’re not clear on the single topic draft we store.

Although I am unclear how a topic you posted would come back as a draft.

I suspect browser plugins? Can you repro via my steps

  1. Went to try.discourse.org
  2. Logged in
  3. Pressed “c” to create a topic
  4. entered title, category, and body using the keyboard
  5. pressed ctrl+enter to submit
  6. topic created OK
  7. Pressed “c” to create another topic… no pre-filled content.

in incognito mode or in a browser you don’t normally use?


(cpradio) #12

Between steps 4 and 5, he is opening links of other topics/the site in new Tabs. So now you have 3 tabs, 1 you are completing a draft, the other two you are browsing around. Complete the topic submission in Tab 1, start a new topic in Tab 2, the draft of your prior topic will likely appear.


(Jeff Atwood) #13

Oh yeah, that will cause problems; your current live topic draft will appear in other tabs and browsers.


(TheLoneCuber) #14

I don’t have any drafts in the other instances though? And it’s not happening if I use the “Create Topic” button.


(TheLoneCuber) #15

Did anyone bother to watch the screencast? It’s crystal clear that I’m not opening any other links or tabs. It’s crystal clear that I don’t navigate away from the task at hand: it is a single operation that starts and finishes on the same tab and Discourse instance.

I repeated the same repo 50 times yesterday (when migrating content to discourse). The clipboard shortcut seen in the video was for the sake of the video (and to save typing) only.


(cpradio) #16

You have to have some sort of draft still hanging around. When I do this on my local dev, it doesn’t happen. The only way I know how to make it happen is having multiple tabs open.


(cpradio) #17

Crap, I see how to reproduce it now.

Okay, so you have to select a Category (can’t choose Uncategorized).

  1. Create a Topic (can be from the /latest page)
  2. Enter Title
  3. Select Category
  4. Enter Content
  5. Create the Topic
    It should redirect you to your new topic within the category you choose
  6. Press c to create a new topic
  7. It pulls up the draft it created for your prior topic in this category.

It has to be related to this line, but I don’t know what to use for the draftKey for this shortcut.
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js#L135


(cpradio) #18

NM, I figured it out
https://github.com/discourse/discourse/pull/2968


(Jeff Atwood) #19

Ah cool. My apologies @TheLoneCuber.

The repro is to have a post draft at the time you are creating a topic and only with the keyboard. Kudos to @cpradio for sticking with it and figuring it out and submitting a fix! :thumbsup:


(Jeff Atwood) #20