Skip to content

Commit 024d936

Browse files
committed
fix searchable dropdown option removal. track search_value, instead of searchable
1 parent f7f8fb4 commit 024d936

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const Dropdown = props => {
3939
const {
4040
id,
4141
clearable,
42-
searchable,
4342
multi,
4443
options,
4544
setProps,
@@ -48,6 +47,7 @@ const Dropdown = props => {
4847
value,
4948
} = props;
5049
const [optionsCheck, setOptionsCheck] = useState(null);
50+
const [searchValue, setSearchValue] = useState(null);
5151
const persistentOptions = useRef(null);
5252

5353
if (!persistentOptions || !isEqual(options, persistentOptions.current)) {
@@ -115,14 +115,14 @@ const Dropdown = props => {
115115
[multi]
116116
);
117117

118-
const onInputChange = useCallback(
119-
search_value => setProps({search_value}),
120-
[]
121-
);
118+
const onInputChange = useCallback(search_value => {
119+
setProps({search_value});
120+
setSearchValue(search_value);
121+
}, []);
122122

123123
useEffect(() => {
124124
if (
125-
!searchable &&
125+
!searchValue &&
126126
!isNil(sanitizedOptions) &&
127127
optionsCheck !== sanitizedOptions &&
128128
!isNil(value)

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import json
22

3+
import pytest
4+
35
from dash import Dash, html, dcc, Output, Input
46
from dash.exceptions import PreventUpdate
57

@@ -11,7 +13,8 @@
1113
]
1214

1315

14-
def test_ddro001_remove_option_single(dash_dcc):
16+
@pytest.mark.parametrize("searchable", (True, False))
17+
def test_ddro001_remove_option_single(dash_dcc, searchable):
1518
dropdown_options = sample_dropdown_options
1619

1720
app = Dash(__name__)
@@ -22,7 +25,7 @@ def test_ddro001_remove_option_single(dash_dcc):
2225
dcc.Dropdown(
2326
options=dropdown_options,
2427
value=value,
25-
searchable=False,
28+
searchable=searchable,
2629
id="dropdown",
2730
),
2831
html.Button("Remove option", id="remove"),
@@ -49,7 +52,8 @@ def on_change(val):
4952
dash_dcc.wait_for_text_to_equal("#value-output", "None")
5053

5154

52-
def test_ddro002_remove_option_multi(dash_dcc):
55+
@pytest.mark.parametrize("searchable", (True, False))
56+
def test_ddro002_remove_option_multi(dash_dcc, searchable):
5357
dropdown_options = sample_dropdown_options
5458

5559
app = Dash(__name__)
@@ -62,7 +66,7 @@ def test_ddro002_remove_option_multi(dash_dcc):
6266
value=value,
6367
multi=True,
6468
id="dropdown",
65-
searchable=False,
69+
searchable=searchable,
6670
),
6771
html.Button("Remove option", id="remove"),
6872
html.Div(id="value-output"),

0 commit comments

Comments
 (0)