# איך להוסיף תפריט נפתח משלי (popupMenu) כמו אפשרויות המלחין?

**URL:** https://meta.discourse.org/t/how-to-add-my-own-drop-down-popupmenu-like-the-composer-options/272314
**Category:** Development
**Tags:** composer
**Created:** [20 ביולי,‏ 2023,‏ 5:34pm UTC](https://meta.discourse.org/t/how-to-add-my-own-drop-down-popupmenu-like-the-composer-options/272314 "2023-07-20T17:34:45Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tyler-mairose-sp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tyler-mairose-sp/32/315587_2.png) [@tyler-mairose-sp](https://meta.discourse.org/u/tyler-mairose-sp)
#### Post date: [20 ביולי,‏ 2023,‏ 5:34pm UTC](https://meta.discourse.org/t/how-to-add-my-own-drop-down-popupmenu-like-the-composer-options/272314/1 "2023-07-20T17:34:45Z")

</div>

I added the following code to my theme component and expected a new popupMenu to appear in the composer.

```js
api.onToolbarCreate(toolbar => {
  toolbar.addButton({
      id: "align_center_button",
      group: "crud",
      icon: "align-center",
      popupMenu: true
  });
});

```

I thought I would be able to follow the code here where the `options` cog gets added and it would work.

```js
        toolbar.addButton({
          id: "options",
          group: "extras",
          icon: "cog",
          title: "composer.options",
          sendAction: this.onExpandPopupMenuOptions.bind(this),
          popupMenu: true,
        });

```

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/4/c/14c90805f907f6c17f49879fa569265a66a24aec.jpeg)

I thought that I could create additional buttons with the group `crud` and they would show up in their own dropdown like the default options. Is this possible? Could I get an example of how to setup and bind options to your own popupMenu?

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [26 ביולי,‏ 2023,‏ 1:03am UTC](https://meta.discourse.org/t/how-to-add-my-own-drop-down-popupmenu-like-the-composer-options/272314/2 "2023-07-26T01:03:21Z")

</div>

I don’t believe our javascript plugin API is set up to make it easy to add a secondary dropdown menu at this point. The toolbar customizations I can think of have all just added options to the existing drop down.

To get _something_ to render you would need to change your `group` to `"extras"`. The groups are [hard-coded](https://github.com/discourse/discourse/blob/85e2f673679bd88b23f3f8908241a03470eb617b/app/assets/javascripts/discourse/app/components/d-editor.js#L57-L61) and relate to the various sections of composer buttons.

The other thing to watch out for is that the `icon` you choose needs to be added via your theme component or the `svg icon subset` site setting.

Beyond that, I’m afraid you’re treading into fairly uncharted territory.

---

<div class="post-metadata">

### Author: ![tyler-mairose-sp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tyler-mairose-sp/32/315587_2.png) [@tyler-mairose-sp](https://meta.discourse.org/u/tyler-mairose-sp)
#### Post date: [27 ביולי,‏ 2023,‏ 1:47pm UTC](https://meta.discourse.org/t/how-to-add-my-own-drop-down-popupmenu-like-the-composer-options/272314/4 "2023-07-27T13:47:23Z")

</div>

Ah okay, that makes a lot of sense for the group sections.

I changed the group back to extras and now it does show up, but now it along with the existing options cog dropdown the same menu.

```javascript
api.onToolbarCreate(toolbar => {
  toolbar.addButton({
      id: "align_center_button",
      group: "extras",
      icon: "align-center",
      popupMenu: true
  });
});

```

Would this be a possible feature to add to the plugin API? The ability to add custom items to your own dropdown independent of the existing options dropdown. I could see this being useful as our composer is starting to look a little cluttered with all the additional options we would like to have 🙂

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [27 ביולי,‏ 2023,‏ 7:00pm UTC](https://meta.discourse.org/t/how-to-add-my-own-drop-down-popupmenu-like-the-composer-options/272314/5 "2023-07-27T19:00:34Z")

</div>

> [@tyler-mairose-sp](#):
>
> Would this be a possible feature to add to the plugin API? The ability to add custom items to your own dropdown independent of the existing options dropdown. I could see this being useful as our composer is starting to look a little cluttered with all the additional options we would like to have 🙂

Totally understand how it could be useful! I see you opened a #Contribute > Feature topic which is perfect. That will help us track interest and hopefully make it so sometime in the future.

---

<div class="post-metadata">

### Author: ![tyler-mairose-sp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tyler-mairose-sp/32/315587_2.png) [@tyler-mairose-sp](https://meta.discourse.org/u/tyler-mairose-sp)
#### Post date: [27 ביולי,‏ 2023,‏ 8:02pm UTC](https://meta.discourse.org/t/how-to-add-my-own-drop-down-popupmenu-like-the-composer-options/272314/6 "2023-07-27T20:02:29Z")

</div>

Thank you @tshenry I appreciate you looking into it!
