Skip to content

Commit 34fd848

Browse files
authored
Merge pull request #2065 from plotly/fix-dropdown-2064
Fix Dropdown with a value but no options.
2 parents 04217e8 + c2f046c commit 34fd848

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1010
[#2003](https://github.com/plotly/dash/issues/2003) in which
1111
`dangerously_allow_html=True` + `mathjax=True` works in some cases, and in some cases not.
1212
- [#2047](https://github.com/plotly/dash/pull/2047) Fix bug [#1979](https://github.com/plotly/dash/issues/1979) in which `DASH_DEBUG` as enviroment variable gets ignored.
13+
- [#2065](https://github.com/plotly/dash/pull/2065) Fix bug [#2064](https://github.com/plotly/dash/issues/2064) rendering of `dcc.Dropdown` with a value but no options.
1314

1415
### Changed
1516

components/dash-core-components/src/fragments/Dropdown.react.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ const Dropdown = props => {
8585
);
8686

8787
useEffect(() => {
88-
if (optionsCheck !== sanitizedOptions && !isNil(value)) {
88+
if (
89+
!isNil(sanitizedOptions) &&
90+
optionsCheck !== sanitizedOptions &&
91+
!isNil(value)
92+
) {
8993
const values = sanitizedOptions.map(option => option.value);
9094
if (multi && Array.isArray(value)) {
9195
const invalids = value.filter(v => !values.includes(v));

components/dash-core-components/tests/integration/dropdown/test_dynamic_options.py

+14
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,17 @@ def test_dddo002_array_comma_value(dash_dcc):
6767
dash_dcc.wait_for_text_to_equal("#react-select-2--value-0", "San Francisco, CA\n ")
6868

6969
assert dash_dcc.get_logs() == []
70+
71+
72+
def test_dddo003_value_no_options(dash_dcc):
73+
app = Dash(__name__)
74+
75+
app.layout = html.Div(
76+
[
77+
dcc.Dropdown(value="foobar", id="dropdown"),
78+
]
79+
)
80+
81+
dash_dcc.start_server(app)
82+
assert dash_dcc.get_logs() == []
83+
dash_dcc.wait_for_element("#dropdown")

0 commit comments

Comments
 (0)