Unsolicited resend of last msg to ui-template node
omrid01 opened this issue · 1 comments
Current Behavior
I'm receiving messages in dashboard ui-template nodes as follows:
<script type="text/javascript">
var $scope = this.scope;
(function(scope) {
$scope.$watch('msg', function(msg)
{
if (msg)
console.log(`Incoming msg: payload=${msg.payload||"None"}`);
// Process the msg
});
})(scope);
</script>
When I load the page (dashboard tab) directly (using .../ui/#!/<n>), everything works OK. However, if I move to this page from another dashboard tab (using the dashboard's hamburger menu), the last received msg is automatically sent again into the template node.
Am I doing something wrong?
Expected Behavior
No response
Steps To Reproduce
I injected a timestamp to the template node, then moved to another tab and came back. The previous timestamp message was resent automatically:
Note that I have unchecked the "Reload last value on refresh" in the template node
Example flow
[
{
"id": "e49fb0bed113e1f8",
"type": "tab",
"label": "Test-init",
"disabled": false,
"info": "",
"env": []
},
{
"id": "e2df5e12686bbd49",
"type": "ui_template",
"z": "e49fb0bed113e1f8",
"group": "9d67e041ac5c0883",
"name": "UI Form",
"order": 2,
"width": "5",
"height": "2",
"format": "<form>\n <h1>Test Page Load</h1>\n</form>\n\n<script type=\"text/javascript\">\nvar $scope = this.scope;\n(function(scope) {\n $scope.$watch('msg', function(msg)\n {\n if (msg)\n console.log(`Incoming msg: payload=${msg.payload||\"None\"}`);\n });\n})(scope);\n</script>\n",
"storeOutMessages": false,
"fwdInMessages": false,
"resendOnRefresh": false,
"templateScope": "local",
"className": "",
"x": 280,
"y": 160,
"wires": [
[]
]
},
{
"id": "f89bd99daeeda980",
"type": "inject",
"z": "e49fb0bed113e1f8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 160,
"wires": [
[
"e2df5e12686bbd49"
]
]
},
{
"id": "9d67e041ac5c0883",
"type": "ui_group",
"name": "Group 1",
"tab": "2a958acb350ce105",
"order": 1,
"disp": true,
"width": 6
},
{
"id": "2a958acb350ce105",
"type": "ui_tab",
"name": "Test-Init",
"icon": "dashboard",
"order": 17,
"disabled": false,
"hidden": false
}
]
Environment
- Node-RED version: 3.1
- Node.js version: 18, 21
- npm version: 9, 10
- Platform/OS: Windows
- Browser: Edge, Chrome
Hi - this repository is for the core of Node-RED. As this appears to be a node-red-dashboard
related issue/question, I'm going to transfer the issue over to that repo.