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

dcc.Dropdown clearing set selected value to option with value="" #2054

Open
HenrikSpiegel opened this issue May 17, 2022 · 1 comment
Open
Labels
bug something broken P3 backlog

Comments

@HenrikSpiegel
Copy link

Describe your context
Please provide us your environment, so we can easily reproduce the issue.

  • replace the result of pip list | grep dash below
dash                              2.1.0
dash-bio                          0.7.1
dash-bootstrap-components         1.0.0
dash-core-components              2.0.0
dash-renderer                     1.9.1
  • if frontend related, tell us your Browser, Version and OS

    • OS: Windows
    • Browser: Chrome
    • Version 101.0.4951.54

Describe the bug

When clearing a dropdown with multi=True it will not clear if there is an option with value="".
Instead when attempting to clear it will show that that an option with value="" has been selected.

Furthermore, if an option with value="" has been selected then all other options where value="" disappears.

  • This is also the case for other values.
    • Tested with multiple options where value = "1"

I suspect it is related to changes in !1970
As this behavior is new and it appears the 1970 fix changes setting the value of dropdowns.

Expected behavior

When deleting the last option one would expect the dropdown to clear and not select value="" option.

Furthermore, it is not appropriate that options that share values are hidden when selected.

Screenshots

Component:

dcc.Dropdown(
  multi=True,
  clearable=True,
  options = [
	  {'label': 'Non-empty-option', 'value':'value'},
	  {'label': 'empty-option-disabled', 'value':'', 'disabled':True},
	  {'label': 'empty-option', 'value':''}
  ]
  )

On initial load:
image

Select option with a value='value'
image

Clear the options:
Note: Clicking either cross does nothing, furthermore, the option labeled 'empty-option' has disappeared from list.
image

We can then select the value='value' option.
we still can't see the 'empty-option' item.
image

Deselect 'empty-option-disabled':
image

Both options with value="" have returned.

@HenrikSpiegel HenrikSpiegel changed the title [BUG] dcc.Dropdown clearable sets to option with value = "" [BUG] dcc.Dropdown clearing set selected value to option with value="" May 17, 2022
@nickmelnikov82
Copy link
Member

Here is a similar problem #1647.
The "value" attribute must be unique.

@gvwilson gvwilson self-assigned this Jul 24, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added P3 backlog bug something broken labels Aug 13, 2024
@gvwilson gvwilson changed the title [BUG] dcc.Dropdown clearing set selected value to option with value="" dcc.Dropdown clearing set selected value to option with value="" Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

3 participants