# UI-Context-Menu shown at all connected browser sessions

**URL:** <https://discourse.nodered.org/t/ui-context-menu-shown-at-all-connected-browser-sessions/34126>\
**Category:** Dashboard\
**Created:** [12 October 2020 13:48 UTC](https://discourse.nodered.org/t/ui-context-menu-shown-at-all-connected-browser-sessions/34126 "2020-10-12T13:48:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![janosch](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@janosch](https://discourse.nodered.org/u/janosch)\
**Post date:** [12 October 2020 13:48 UTC](https://discourse.nodered.org/t/ui-context-menu-shown-at-all-connected-browser-sessions/34126/1 "2020-10-12T13:48:27Z")

</div>

Hi all,  
i recently connect a ui\_button node to a ui\_context\_menu node to trigger a custom popup menu on button click. I realized, when I have two or more browser sessions opened on my dashboard (for instance from desktop and mobile) the menu pops up at all sessions at the same time.  
I expected it to be shown only for the session where the button is clicked ...  
Did I miss something or is it due to the single-user restriction of nodered-dashboard?

To demonstrate this, here is a simple flow:

```auto
[{"id":"e86e3797.bc76d8","type":"tab","label":"context-menu-test","disabled":false,"info":""},{"id":"9a3d63ee.afcae","type":"ui_context_menu","z":"e86e3797.bc76d8","group":"38a63b85.6089ac","order":1,"width":0,"height":-1,"fontSize":16,"inputPositionXField":"event.clientX","inputPositionXType":"msg","inputPositionYField":"event.clientY","inputPositionYType":"msg","outputField":"payload","inputMenuField":"menu","inputMenuType":"fixed","menuItems":[{"id":"item1","icon":"fa-star","label":"item-1","topic":"","payload":"","payloadType":"str","visible":true,"enabled":true},{"id":"item2","icon":"fa-heart","label":"item-2","topic":"","payload":"","payloadType":"str","visible":true,"enabled":true}],"colors":"native","textColor":"#000000","backgroundColor":"#ffffff","borderColor":"#626262","intervalLength":0,"intervalUnit":"secs","startTimerAtOpen":false,"startTimerAtLeave":true,"stopTimerAtEnter":true,"name":"popup","x":590,"y":200,"wires":[[]]},{"id":"6e1b4ec2.4774b","type":"ui_button","z":"e86e3797.bc76d8","name":"button","group":"38a63b85.6089ac","order":0,"width":0,"height":0,"passthru":false,"label":"Click me","tooltip":"","color":"","bgcolor":"","icon":"menu","payload":"","payloadType":"str","topic":"","x":430,"y":200,"wires":[["9a3d63ee.afcae"]]},{"id":"38a63b85.6089ac","type":"ui_group","z":"","name":"context-menu-test","tab":"d81e78f0.ebcac8","order":3,"disp":true,"width":"6","collapse":false},{"id":"d81e78f0.ebcac8","type":"ui_tab","z":"","name":"Home","icon":"home","order":1,"disabled":false,"hidden":false}]

```

When I click the button on my mobile, the menu gets also visible on my desktop. And even stays visible after i clicked a menu item on my mobile (at least if I do not specify a timeout in the menu's properties page).

Any suggestions about what I'm wrong are welcome!

janosch

Just found following statement at the beginning of this interesting post:  
[https://discourse.nodered.org/t/dashboard-text-input-node-avoid-global-state/30744](https://discourse.nodered.org/t/dashboard-text-input-node-avoid-global-state/30744)

> Just like the ui-contextmenu doesn't reply messages on new clients, because we don't want the contextmenu of another user to popup.

Gives me the hint my expectations are right?

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [13 October 2020 19:26 UTC](https://discourse.nodered.org/t/ui-context-menu-shown-at-all-connected-browser-sessions/34126/2 "2020-10-13T19:26:13Z")

</div>

Hi @janosch,

Very strange that you are the first one reporting this problem ...

Seemed that I created a new message in the `beforeEmit` and I forgot to copy the `socketid` from the original message, so the dashboard thought that the message had to be sent to all the dashboard sessions. I have solved it via [this](https://discourse.nodered.org/t/dashboard-socket-id-bug/6229/6) nice trick from our friend @dceejay.

I have published version _ **2.0.1** _ of the node-red-contrib-ui-contextmenu node on NPM. Now the contextmenu is only displayed in the dashboard session where the button is being clicked (based on the `socketid`of that particular session):

![contextmenu_socketid](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/3/d379d67c4d21a4c58f12c55043d902e1bd9edba6.gif)

Can you please confirm me if it works!  
Bart

---

<div class="post-metadata">

**Author:** ![janosch](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@janosch](https://discourse.nodered.org/u/janosch)\
**Post date:** [14 October 2020 19:29 UTC](https://discourse.nodered.org/t/ui-context-menu-shown-at-all-connected-browser-sessions/34126/3 "2020-10-14T19:29:09Z")

</div>

Hi @BartButenaers,  
just installed Version **2.0.1** of the context menu as you proposed, and what shall I say ...  
It works as expected!  
Great job, thank you very much.  
I really appreciate! 👍

Thanks also to @dceejay.  
I expected it has something to do with socketid, but couldn't figure out how to work around this.

Best regards  
jan

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 October 2020 19:29 UTC](https://discourse.nodered.org/t/ui-context-menu-shown-at-all-connected-browser-sessions/34126/4 "2020-10-28T19:29:09Z")

</div>

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