Convert the New Topic button to a have a sub menu

Hey guys,

Does any one know how i can go about making the New Topic button have a sub menu on certain categories?

Currently i have this

But was hoping to get something like this when the “New Topic” button is clicked

I can think of a few ways to do this but not sure if i’m over thinking it, hiding the stock button and adding a whole new button with the dropdown was one of the ideas i had.

This is the current code i have, before i do it the way i said above, is there a way to just add a menu entry easily?

<script type="text/x-handlebars" data-template-name="/connectors/before-create-topic-button/syncbutton"> 
  <button onclick="window.location.href='/w/issue-with-sync3'" class="btn-default btn btn-icon-text ember-view customnewtopicbtn" title="Create a new topic using the SYNC 3 Issue template">
    <svg class="fa d-icon d-icon-plus svg-icon svg-string" xmlns=""><use xlink:href="#plus"></use></svg>
    <span class="d-button-label">New Sync Issue</span>

Also if i do hide the “Create Topic” button is there some variable or function i can use to retrive the link for the “New Topic” button?

EDIT: or rather how is the New Topic section opened, i thought it would be from clicking the button matching a ID or class but it seems this isn’t the case?



You can have a look at this theme component:

It adds a dropdown button to the header and I might still make a few changes. But it should give an idea how to replace the default button and how opening and pre-filling the composer works.


Thanks, this might work, i’ll look in to it.

I guess my problem now is how i put that in the Topic List buttons, as it seems you can’t use DecorateWidget with plugin outlets.

1 Like

Ah yeah, now I remember that’s why I didn’t publish it… I still wanted to make it more flexible and offer to insert the button at various places. But I hadn’t figured out how to add the widget when there’s only a plugin outlet. Maybe someone knows a good approach to this?

1 Like

Hehe :slight_smile: i found this, but my skill isn’t really in javscript :laughing: so not sure it’s any use

Nice work so far though :slight_smile:

1 Like

Oh I just did something like this last week…

Screen Shot 2021-12-16 at 11.01.16 AM

In a theme you can add this to javascripts/discourse/components/new-topic-dropdown.js

import { action } from "@ember/object";
import { getOwner } from "discourse-common/lib/get-owner";
import Composer from "discourse/models/composer";
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import { computed } from "@ember/object";

export default DropdownSelectBoxComponent.extend({
  classNames: ["new-topic-dropdown"],

  selectKitOptions: {
    icons: ["plus"],
    showFullTitle: true,
    autoFilterable: false,
    filterable: false,
    showCaret: true,
    none: "topic.create",

  content: computed(function () {
    const items = [
        id: "new_discussion",
        name: "New Topic",
        description: "Start a new discussion",
        icon: "comment",

      id: "new_ticket",
      name: "Support ticket",
      description: "Start a support request",
      icon: "tag",

    return items;

  onChange(selectedAction) {
    const composerController = getOwner(this).lookup("controller:composer");

    let tags = null;
    let categoryId = this.category ? : null;

    if (selectedAction === "new_ticket") {
      tags = "ticket";
      action: Composer.CREATE_TOPIC,
      draftKey: Composer.DRAFT,
      categoryId: categoryId,
      tags: tags,

This adds “new topic” and “support ticket” options to a dropdown button… “new topic” opens the composer as usual, and “support ticket” opens the composer with the tag “ticket” already added.

…and then in javascripts/discourse/connectors/after-create-topic-button/new-topic-dropdown.hbs

{{#if currentUser}}
  {{new-topic-dropdown category=category}}

…then with some CSS you’ll probably want to hide the default button:

.navigation-controls {
  #create-topic {
    display: none;

Absolute legend :slight_smile: Thanks