UI-Context-Menu shown at all connected browser sessions

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:

[{"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

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?

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 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 socketidof that particular session):

contextmenu_socketid

Can you please confirm me if it works!
Bart

1 Like

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! :+1:

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

1 Like