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

ui-dropdown doesn't clear selection with msg.payload = [] #756

Closed
18802496555 opened this issue Apr 7, 2024 · 8 comments · Fixed by #775
Closed

ui-dropdown doesn't clear selection with msg.payload = [] #756

18802496555 opened this issue Apr 7, 2024 · 8 comments · Fixed by #775
Labels
bug Something isn't working needs-triage Needs looking at to decide what to do

Comments

@18802496555
Copy link

Current Behavior

after selected an option, by sending msg.payload=[] will not clear seletion as documented

Expected Behavior

by send msg.payload =[] to ui-dropdown node will clear selection

Steps To Reproduce

[{"id":"b878241ae48df373","type":"inject","z":"b481f6a7426a1928","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":630,"y":1060,"wires":[["fc2672e929484423"]]},{"id":"fc2672e929484423","type":"function","z":"b481f6a7426a1928","name":"function 21","func":"msg.payload = [];\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":810,"y":1060,"wires":[["f45a08fdd76cf08f"]]},{"id":"f45a08fdd76cf08f","type":"ui-dropdown","z":"b481f6a7426a1928","group":"e039e314bc87dbdd","name":"test","label":"test","tooltip":"","order":0,"width":"3","height":"1","passthru":true,"multiple":false,"options":[{"label":"a","value":"1","type":"str"},{"label":"b","value":"2","type":"str"},{"label":"c","value":"3","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":990,"y":1060,"wires":[["5ad6a6f2fc2c422e"]]},{"id":"5ad6a6f2fc2c422e","type":"debug","z":"b481f6a7426a1928","name":"debug 208","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1140,"y":1060,"wires":[]},{"id":"e039e314bc87dbdd","type":"ui-group","name":"按键选择","page":"ce60fd917fc93e18","width":"12","height":"1","order":-1,"showTitle":true,"className":"","visible":"true","disabled":"false"},{"id":"ce60fd917fc93e18","type":"ui-page","name":"场景管理","ui":"bbbca6a8a7b43502","path":"/page4","icon":"home","layout":"grid","theme":"a320a731ce51b7c0","order":4,"className":"","visible":"true","disabled":"false"},{"id":"bbbca6a8a7b43502","type":"ui-base","name":"管理面板","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"navigationStyle":"fixed"},{"id":"a320a731ce51b7c0","type":"ui-theme","name":"Default Theme","colors":{"surface":"#24292e","primary":"#097479","bgPage":"#111111","groupBg":"#333333","groupOutline":"#cccccc"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

Environment

  • Dashboard version: 2.0
  • Node-RED version: 3.18
  • Node.js version:
  • npm version:
  • Platform/OS: hassio
  • Browser: edge

Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

@18802496555 18802496555 added bug Something isn't working needs-triage Needs looking at to decide what to do labels Apr 7, 2024
@colinl
Copy link
Contributor

colinl commented Apr 7, 2024

I can confirm that sending an empty array does not clear it, and neither does an empty string. However, if the node is changed to multi-select then an empty array does clear it.

@18802496555
Copy link
Author

is this a bug or it is designed to work only with multi-selection?

@colinl
Copy link
Contributor

colinl commented Apr 7, 2024

There is a bug, there should be a way of clearing single selection dropdowns. Whether, for single selection, it should be an empty string (which seems logical to me) or should still be an empty array I will leave to the developers. Perhaps both options should work in both cases.

@bartbutenaers
Copy link
Contributor

@colinl,
Last week I had created a pull request for dynamic control of radiobuttons, which can be cleared using an empty string. I will have a look to create a PR to do the same for drpodowns tonight.
Bart

@colinl
Copy link
Contributor

colinl commented Apr 16, 2024

The docs currently say it should be an empty array. Whether it should also allow an empty string I don't know.

@bartbutenaers
Copy link
Contributor

Yes indeed. An empty array seems to make more sense to me compared to an empty string, because the dropdown can contain different kind of data types (i.e. not only strings):

image

@bartbutenaers
Copy link
Contributor

Pull request created.

@joepavitt
Copy link
Collaborator

Closed by #775

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Needs looking at to decide what to do
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants