Navigation with minimized topic draft can trigger abandon dialog

AI-generated summary

A user, tshenry, reported an issue with navigation in Discourse when a topic draft is minimized. When navigating from a topic to a category with a minimized topic draft editor, the โ€œabandon postโ€ dialog appears. However, when the editor is fully expanded, the dialog does not appear. tshenry is unsure if this behavior is intentional or a bug.

tshenry further investigated and found that the issue only occurs with topic drafts, not reply drafts. They also discovered a related code change made a few years ago and suggested it might be causing the behavior.

tshenry provided a screen recording of the issue to help illustrate the problem. However, sam has marked the issue as stale and is waiting for tshenry to confirm if the issue still exists after recent topic draft changes.

Hi there, hope everyone is having a great day :grinning:

I noticed some interesting differences in behavior between navigating around Discourse with a topic draft editor expanded vs minimized.

If the topic editor is minimized, any time you navigate from a topic to a category, you get prompted with the โ€œabandon postโ€ dialog. If the editor is fully expanded and you navigate in the same manner, the dialog does not appear.

Is this behavior intentional or a bug? The main reason I could see this as intentional is to remind you that you have a draft it progress, but it seems odd to bring up the โ€œabandon postโ€ dialog simply upon navigation. It feels like that dialog should be reserved for when you click โ€œNew Topic.โ€ If the main idea was to remind the user, it seems more appropriate to either automatically expand a minimized draft or display some type of reminder dialog.

Let me know what you think or if I need to be any clearer in what Iโ€™m trying to explain!

4๊ฐœ์˜ ์ข‹์•„์š”

Just topic draft does this, or reply draft?

Iโ€™ve only had it happen with the topic draft. I just tried it with a reply draft and couldnโ€™t reproduce it.

Iโ€™m just starting to try to familiarize myself with Discourse code, so this may be a dumb suggestion, but I did some digging and there was a fix made a few years ago:

https://github.com/discourse/discourse/commit/359f03ca73f92bcc8bf25140ab96e2b9b8cc87f7#diff-63b31ab42d152f878f4fb06d7e6b4775

I saw this addition:

  // If there's a draft, open the create topic composer
  if (model.draft) {
    this.controllerFor('composer').open({
      action: Discourse.Composer.CREATE_TOPIC,
      draft: model.draft,
      draftKey: model.draft_key,
      draftSequence: model.draft_sequence
    });
  }

Would an action like that being called during navigation be whatโ€™s producing what appears to be the behavior you would expect if you clicked the โ€œNew Topicโ€ button with a draft in place?

1๊ฐœ์˜ ์ข‹์•„์š”

Hereโ€™s a screen recording of the issue. You will see the issue as I navigate to a couple of different categories with the editor minimized, then at the end I show that there is no issue when the editor is expanded.

https://streamable.com/1cri9

3๊ฐœ์˜ ์ข‹์•„์š”

I am going to close this as stale, @tshenry flag if this is still an issue in light of the topic draft changes I made.

1๊ฐœ์˜ ์ข‹์•„์š”