# “New topic” button working incorrectly

**URL:** https://meta.discourse.org/t/new-topic-button-working-incorrectly/270071
**Category:** Support
**Created:** [June 29, 2023, 6:51pm UTC](https://meta.discourse.org/t/new-topic-button-working-incorrectly/270071 "2023-06-29T18:51:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Calion](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/calion/32/164230_2.png) [@Calion](https://meta.discourse.org/u/Calion)
#### Post date: [June 29, 2023, 6:51pm UTC](https://meta.discourse.org/t/new-topic-button-working-incorrectly/270071/1 "2023-06-29T18:51:18Z")

</div>

When I hit the “New topic” button it does not immediately bring up the new topic form. Instead, the form is displayed after I select one of the threads in the forum. It still appears that it is creating a new topic, but in the background. Once you open any existing topic, the new topic you were trying to create appears (completely correct; i.e. for the forum you intended to post in, even if the topic you entered is in a different forum).

This is only happening on one site ([https://discussions.scouting.org/](https://discussions.scouting.org/)), so I presume it’s something they have configured incorrectly. I’ve brought this issue up [there](https://discussions.scouting.org/t/new-topic-button-not-working-correctly/308140), to no avail.

---

<div class="post-metadata">

### Author: ![ondrej](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ondrej/32/198804_2.png) [@ondrej](https://meta.discourse.org/u/ondrej)
#### Post date: [June 29, 2023, 8:15pm UTC](https://meta.discourse.org/t/new-topic-button-working-incorrectly/270071/3 "2023-06-29T20:15:44Z")

</div>

Does this occur in [safe mode](https://meta.discourse.org/t/53504?silent=true)?

---

<div class="post-metadata">

### Author: ![isaac](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/isaac/32/235758_2.png) [@isaac](https://meta.discourse.org/u/isaac)
#### Post date: [June 29, 2023, 10:01pm UTC](https://meta.discourse.org/t/new-topic-button-working-incorrectly/270071/4 "2023-06-29T22:01:05Z")

</div>

This is not reproducible in [safe mode](https://meta.discourse.org/t/53504?silent=true). There is a custom theme / css that is causing this issue.

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [June 30, 2023, 5:51pm UTC](https://meta.discourse.org/t/new-topic-button-working-incorrectly/270071/5 "2023-06-30T17:51:44Z")

</div>

The admins have added a CSS customization that looks like this:

```css
body:not([class*="category-council-"]):not(.staff).closed-topic .reply, 
body:not([class*="category-council-"]):not(.staff).closed-topic #topic-footer-buttons .create, 
body:not([class*="category-council-"]):not(.staff).closed-topic .timeline-container .create, 
body:not([class*="category-council-"]):not(.staff).closed-topic #reply-control {
  display: none !important;
}

```

This appears to be ok at initial glance, but then I can see `body.closed-topic` is applied to the topic list… which really doesn’t make sense.

This class isn’t in Discourse by default, so tracking down another customization that adds that…

```xml
<script type="text/discourse-plugin" version="0.8">
const container = Discourse. __container__ ;
const controller = container.lookup("controller:topic");
const currentUser = api.getCurrentUser();

api.onPageChange(() => {

  if (!currentUser || currentUser.admin || currentUser.moderator || currentUser.trust_level != 4 ) {
    return;
  } else {
    let model = controller.get("model");
    
    document.querySelector("body").classList.add("closed-topic");
    
    if (model) {
      if (!model.closed) {
        document.querySelector("body").classList.remove("closed-topic");
      }
    }
  }

});
</script>

```

So here, if you’re logged in, not an admin, not a moderator, and are trust level 4… then it adds the `closed-topic` class to the page body.

This class is only removed if `model.closed` is false, which means… if it’s not a closed topic (or even if it’s not a topic at all) the `closed-topic` class will be applied.

This line:

`document.querySelector("body").classList.add("closed-topic");`

should probably be within `if (model)` because otherwise it’s applied even when there’s no model present (e.g., when you’re not within a topic)…

It seems the intention was to prevent trust level 4 users from replying to closed topics, but it’s applied too broadly.

---

<div class="post-metadata">

### Author: ![Calion](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/calion/32/164230_2.png) [@Calion](https://meta.discourse.org/u/Calion)
#### Post date: [July 4, 2023, 7:03pm UTC](https://meta.discourse.org/t/new-topic-button-working-incorrectly/270071/8 "2023-07-04T19:03:18Z")

</div>

Thanks much, this is what I was looking for.

---

<div class="post-metadata">

### Author: ![Calion](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/calion/32/164230_2.png) [@Calion](https://meta.discourse.org/u/Calion)
#### Post date: [July 4, 2023, 7:12pm UTC](https://meta.discourse.org/t/new-topic-button-working-incorrectly/270071/9 "2023-07-04T19:12:22Z")

</div>

> [@awesomerobot](#):
>
> It seems the intention was to prevent trust level 4 users from replying to closed topics, but it’s applied too broadly.

Heheh I wonder if I’m the reason for that change. I discovered that bug and exploited it liberally. I never grasped the reason to require people to start a new thread when you’ve got additional information to add to an old one.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [August 3, 2023, 7:12pm UTC](https://meta.discourse.org/t/new-topic-button-working-incorrectly/270071/10 "2023-08-03T19:12:44Z")

</div>

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