node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

ui-notification does not preserve the injected topic, except for initial emitted message

Open Dowster64 opened this issue 3 months ago • 1 comments

Current Behavior

When the ui-notification, triggered by a button with both a topic and a payload, which has a dismiss and a confirm button it immediately emits a message with msg.payload and msg.topic = to the triggering button's payload and topic. When the notification times out, is dismissed or confirmed the msg.payload reflects what happened (e.g. msg.payload = "confirm_clicked") but the msg.topic is now undefined.

Expected Behavior

I expected the msg.topic from the initial trigger of the ui-notification to be kept, so I could use it in a switch and change node to manage the flow of messages in the flow. I came across this when I tried to remove the duplication of ui-notification and switch nodes.

Steps To Reproduce

Here is an example flow:

[{"id":"9acdb40f381834be","type":"tab","label":"Flow 3","disabled":false,"info":"","env":[]},{"id":"634762e4d894842d","type":"ui-notification","z":"9acdb40f381834be","ui":"e60a16970ec790b6","position":"center center","colorDefault":true,"color":"#000000","displayTime":"5","showCountdown":true,"outputs":1,"allowDismiss":true,"dismissText":"Cancel","allowConfirm":true,"confirmText":"Confirm","raw":true,"className":"","name":"","x":280,"y":120,"wires":[["84e270cf09746b1e"]]},{"id":"bf33f58aa8e8ae7c","type":"ui-button","z":"9acdb40f381834be","group":"4ad55f76a1421760","name":"","label":"PowerOff","order":1,"width":0,"height":0,"emulateClick":true,"tooltip":"","color":"","bgcolor":"","className":"","icon":"","iconPosition":"left","payload":"Confirm Power Off","payloadType":"str","topic":"poweroff","topicType":"str","buttonColor":"","textColor":"","iconColor":"","enableClick":true,"enablePointerdown":false,"pointerdownPayload":"","pointerdownPayloadType":"str","enablePointerup":false,"pointerupPayload":"","pointerupPayloadType":"str","x":120,"y":80,"wires":[["634762e4d894842d"]]},{"id":"e752c8aceae41057","type":"ui-button","z":"9acdb40f381834be","group":"4ad55f76a1421760","name":"","label":"Reboot","order":2,"width":0,"height":0,"emulateClick":true,"tooltip":"","color":"","bgcolor":"","className":"","icon":"","iconPosition":"left","payload":"Confirm Reboot","payloadType":"str","topic":"reboot","topicType":"str","buttonColor":"","textColor":"","iconColor":"","enableClick":true,"enablePointerdown":false,"pointerdownPayload":"","pointerdownPayloadType":"str","enablePointerup":false,"pointerupPayload":"","pointerupPayloadType":"str","x":120,"y":160,"wires":[["634762e4d894842d"]]},{"id":"84e270cf09746b1e","type":"switch","z":"9acdb40f381834be","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"confirm_clicked","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":120,"wires":[["ba77a8f3f24e0acd","ee596c6aa92f1b5d"],["03e217515436f284"]]},{"id":"dbfa18326a26ae03","type":"debug","z":"9acdb40f381834be","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":280,"wires":[]},{"id":"ba77a8f3f24e0acd","type":"debug","z":"9acdb40f381834be","name":"confirm_clicked","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":340,"wires":[]},{"id":"03e217515436f284","type":"debug","z":"9acdb40f381834be","name":"notification name, dismiss or timeout","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":400,"wires":[]},{"id":"e355aad95410b88d","type":"inject","z":"9acdb40f381834be","name":"reboot test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"reboot","payload":"confirm_clicked","payloadType":"str","x":340,"y":240,"wires":[["84e270cf09746b1e"]]},{"id":"ee596c6aa92f1b5d","type":"change","z":"9acdb40f381834be","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":220,"wires":[["dbfa18326a26ae03"]]},{"id":"a9ae9437259f5dd0","type":"inject","z":"9acdb40f381834be","name":"poweroff test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"poweroff","payload":"confirm_clicked","payloadType":"str","x":310,"y":280,"wires":[["84e270cf09746b1e"]]},{"id":"e60a16970ec790b6","type":"ui-base","name":"My Dashboard","path":"/dashboard","appIcon":"","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"headerContent":"page","navigationStyle":"default","titleBarStyle":"default","showReconnectNotification":true,"notificationDisplayTime":1,"showDisconnectNotification":true,"allowInstall":true},{"id":"4ad55f76a1421760","type":"ui-group","name":"Group 1","page":"1fba21f77e7bda22","width":6,"height":1,"order":1,"showTitle":true,"className":"","visible":true,"disabled":false,"groupType":"default"},{"id":"1fba21f77e7bda22","type":"ui-page","name":"Page 1","ui":"e60a16970ec790b6","path":"/page1","icon":"home","layout":"grid","theme":"8a81eb2c8b512dd3","breakpoints":[{"name":"Default","px":0,"cols":3},{"name":"Tablet","px":576,"cols":6},{"name":"Small Desktop","px":768,"cols":9},{"name":"Desktop","px":1024,"cols":12}],"order":1,"className":"","visible":"true","disabled":"false"},{"id":"8a81eb2c8b512dd3","type":"ui-theme","name":"Default Theme","colors":{"surface":"#ffffff","primary":"#0094CE","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"},"sizes":{"density":"default","pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}},{"id":"51cdd2e9b288517b","type":"global-config","env":[],"modules":{"@flowfuse/node-red-dashboard":"1.27.2"}}]

Environment

  • Dashboard version: 1.27.2
  • Node-RED version: 4.1.0
  • Node.js version: 20.19.5
  • npm version: 10.8.2
  • Platform/OS: Raspberry Pi Linux xxxxx 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
  • Browser: Firefox 143.0.1 (64-bit)

Have you provided an initial effort estimate for this issue?

I am not a FlowFuse team member

Dowster64 avatar Sep 25 '25 07:09 Dowster64

I can confirm that I can replicate the problem. I think there are two issues here, the node should not pass on the initial message sent in, and the topic should not be lost when it completes.

A workaround is to move msg.topic to another property, eg msg.savedTopic, as the rest of the message is passed on correctly, at least I think that is the case. Not time to test at the moment.

colinl avatar Sep 25 '25 08:09 colinl