# Topic template should update when the post category is changed

**URL:** https://meta.discourse.org/t/topic-template-should-update-when-the-post-category-is-changed/33012
**Category:** Bug
**Created:** [September 8, 2015, 6:40am UTC](https://meta.discourse.org/t/topic-template-should-update-when-the-post-category-is-changed/33012 "2015-09-08T06:40:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![calmh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/calmh/32/115466_2.png) [@calmh](https://meta.discourse.org/u/calmh)
#### Post date: [September 8, 2015, 6:40am UTC](https://meta.discourse.org/t/topic-template-should-update-when-the-post-category-is-changed/33012/1 "2015-09-08T06:40:34Z")

</div>

Continuing the discussion from [Topic Templates](https://meta.discourse.org/t/topic-templates/18282/36):

I have a forum where a single category would benefit from a topic template - the “support” category, as may be typical. This is the most used category, so it’s the default when anyone hits the “new topic” button so they get the topic template in question.

The problem is that if they change their post category, the (now irrelevant) topic template doesn’t go away (i.e. change to the blank template that is the setting for that other category). Likewise if you change to another category that _does_ have a topic template, you are still left with the old topic template.

I get that the current behavior is “only set the template if the post was blank” to avoid stomping on user changes. That makes sense. However, it seems the better behavior may be “set the template if the post is blank _or matches the template of the category I’m deselecting_”?

Or possibly, have a simple “dirty” flag for the post that is initially false. When the user makes any edit (keypress) in the editor, set it to true. When changing the post category, replace the contents with the topic template if the dirty flag is false.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [September 9, 2015, 8:30pm UTC](https://meta.discourse.org/t/topic-template-should-update-when-the-post-category-is-changed/33012/2 "2015-09-09T20:30:57Z")

</div>

I’ve fixed it so that if you don’t change the template, it will be swapped out when you change the category:

[https://github.com/discourse/discourse/commit/ca8046c7c3f3d22124a1bd8d34d81ddc6c32a9e2](https://github.com/discourse/discourse/commit/ca8046c7c3f3d22124a1bd8d34d81ddc6c32a9e2)

---

<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: [September 11, 2015, 8:32pm UTC](https://meta.discourse.org/t/topic-template-should-update-when-the-post-category-is-changed/33012/3 "2015-09-11T20:32:20Z")

</div>

This topic was automatically closed after 2 days. New replies are no longer allowed.
