Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button label will disappear after browser reload if the label set by a message property #499

Closed
6 tasks done
wongnam opened this issue May 20, 2019 · 6 comments
Closed
6 tasks done
Labels

Comments

@wongnam
Copy link

wongnam commented May 20, 2019

What are the steps to reproduce?

  • Open the dashboard and press the button
  • the button will has a label eg PUSH TO CLOSE or PUSH TO OPEN
  • Reload the dashboard by pressing F5 on keyboard or click "Reload this page" on web browser taskbar.
  • the Label on the button will disappear.

What do you expect to happen?

  • It should display even the page was reload.

Please tell us about your environment:

  • Node-RED-Dashboard version: 2.15.2
  • Node-RED version: 0.19.5
  • node.js version: v8.12.0
  • npm version: 6.9.0
  • Platform/OS: Raspberry Pi 3B+ / Raspbian Stretch
  • Browser: MS Edge, Google Chrome

Screen shot and sample flow:

image

[{"id":"282cfbce.780ca4","type":"ui_button","z":"dceadd9d.ba53c","name":"Button","group":"bd4c84d3.a8f078","order":1,"width":0,"height":0,"passthru":false,"label":"{{msg.topic}}","tooltip":"","color":"","bgcolor":"","icon":"","payload":"TOGGLE","payloadType":"str","topic":"","x":580,"y":1670,"wires":[["353d58d3.97a238","51215a9a.3fcfc4"]]},{"id":"51215a9a.3fcfc4","type":"function","z":"dceadd9d.ba53c","name":"Toggle-> True/False","func":"if (msg.payload==\"TOGGLE\"){ \ncontext.set('value', context.get('value')||false);    \nvar value = context.get('value');\n\nswitch (value) {\n    case true:\n        context.set('value', false);\n        msg.payload = 'false';\n        break;\n    case false:\n        context.set('value', true);\n        msg.payload = 'true';\n        break;\n    default:\n        context.set('value', false);\n        msg.payload = 'false';\n        break;\n}\n\nreturn msg;\n}\nif (msg.payload!=\"TOGGLE\"){\n    context.set('value', msg.payload);\n}\n    ","outputs":1,"noerr":0,"x":330,"y":1560,"wires":[["56613497.23bf7c"]]},{"id":"56613497.23bf7c","type":"switch","z":"dceadd9d.ba53c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":100,"y":1670,"wires":[["7fb5d2ef.55b08c"],["a5def383.0e12c"]]},{"id":"7fb5d2ef.55b08c","type":"change","z":"dceadd9d.ba53c","name":"msg.topic = \"PUSH TO OPEN\"","rules":[{"t":"set","p":"topic","pt":"msg","to":"PUSH TO OPEN","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":1650,"wires":[["282cfbce.780ca4"]]},{"id":"a5def383.0e12c","type":"change","z":"dceadd9d.ba53c","name":"msg.topic = \"PUSH TO CLOSE\"","rules":[{"t":"set","p":"topic","pt":"msg","to":"PUSH TO CLOSE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":1690,"wires":[["282cfbce.780ca4"]]},{"id":"353d58d3.97a238","type":"debug","z":"dceadd9d.ba53c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":1670,"wires":[]},{"id":"bd4c84d3.a8f078","type":"ui_group","z":"","name":"Testing SW/Button","tab":"71576856.c06de8","order":2,"disp":true,"width":"6","collapse":false},{"id":"71576856.c06de8","type":"ui_tab","z":"","name":"Testing","icon":"fa-edit","order":7}]
@dceejay
Copy link
Member

dceejay commented May 20, 2019

The label is not part of the state of any widget - only the payload is held as state. If you need to set the label at a refresh then the ui_control node can be used to trigger a resend of the label you require.
This has always been the case.

@wongnam
Copy link
Author

wongnam commented May 20, 2019

When I used version 2.14.0 everything worked as expected, I just noticed this situation happened after upgrading version 2.15.2
I don't know if it was intentional or unintentional change in the versions from now on.

@dceejay
Copy link
Member

dceejay commented May 20, 2019

thanks - gives me a clue where to look.

@wongnam
Copy link
Author

wongnam commented May 21, 2019

Thanks,
It has been partially fixed. however, the button is pressed, the label will still disappear when the web page is reloaded. So I have to re-inject the label again instead of not having to re-inject as the previous version.

What are the steps to reproduce?

  • Press to inject a label
  • reload the page, the label is still display in the button. -> it's worked as expected.
  • Press the "Button"
  • try to reload the page, the Label will disappear -> This is an unexpected issue.

Try this sample flow:

[{"id":"df586931.c73978","type":"ui_button","z":"747e54bf.55397c","name":"","group":"966e76b8.e7bf98","order":3,"width":0,"height":0,"passthru":false,"label":"{{msg.topic}}","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Toggle","payloadType":"str","topic":"","x":590,"y":200,"wires":[[]]},{"id":"9c8849af.5018c8","type":"ui_button","z":"747e54bf.55397c","name":"","group":"966e76b8.e7bf98","order":1,"width":0,"height":0,"passthru":false,"label":"Press to Inject a Label 1","tooltip":"","color":"","bgcolor":"","icon":"","payload":"BUTTON 1","payloadType":"str","topic":"","x":170,"y":200,"wires":[["c9dcd76e.6a7d38"]]},{"id":"c9dcd76e.6a7d38","type":"change","z":"747e54bf.55397c","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":200,"wires":[["df586931.c73978"]]},{"id":"defd481e.48db98","type":"ui_button","z":"747e54bf.55397c","name":"","group":"966e76b8.e7bf98","order":2,"width":0,"height":0,"passthru":false,"label":"Press to Inject a Label 2","tooltip":"","color":"","bgcolor":"","icon":"","payload":"BUTTON 2","payloadType":"str","topic":"","x":170,"y":160,"wires":[["c9dcd76e.6a7d38"]]},{"id":"966e76b8.e7bf98","type":"ui_group","z":"","name":"Default","tab":"da5a9d53.2af25","order":2,"disp":true,"width":"6","collapse":false},{"id":"da5a9d53.2af25","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

@dceejay
Copy link
Member

dceejay commented May 21, 2019

refixed

@dceejay dceejay added this to Work in Progress in Dashboard - Things to do May 21, 2019
dceejay pushed a commit that referenced this issue May 21, 2019
dceejay pushed a commit that referenced this issue May 21, 2019
to close #499
(add dist files)
@wongnam
Copy link
Author

wongnam commented May 22, 2019

Thank you very much. it works as expected.

@dceejay dceejay moved this from Work in Progress to Released to npm - 2.15.0, 1, 2, 3 in Dashboard - Things to do May 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants