This repository was archived by the owner on Jun 3, 2024. It is now read-only.
File tree 2 files changed +43
-0
lines changed
tests/integration/dropdown 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,12 @@ export default class Dropdown extends Component {
74
74
value = { selectedValue }
75
75
onChange = { selectedOption => {
76
76
if ( multi ) {
77
+ if (
78
+ ! this . props . clearable &&
79
+ selectedOption . length < 1
80
+ ) {
81
+ return ;
82
+ }
77
83
let value ;
78
84
if ( isNil ( selectedOption ) && this . props . clearable ) {
79
85
value = [ ] ;
Original file line number Diff line number Diff line change @@ -39,3 +39,40 @@ def update_value(val):
39
39
dash_duo .find_element ('#dropdown-value' ).click ()
40
40
41
41
assert len (dash_duo .find_element ('#dropdown-value' ).text ) > 0
42
+
43
+
44
+ def test_ddcf002_clearable_false_multi (dash_duo ):
45
+ app = dash .Dash (__name__ )
46
+ app .layout = html .Div ([
47
+ dcc .Dropdown (
48
+ id = 'my-unclearable-dropdown' ,
49
+ options = [
50
+ {'label' : 'New York City' , 'value' : 'NYC' },
51
+ {'label' : 'Montreal' , 'value' : 'MTL' },
52
+ {'label' : 'San Francisco' , 'value' : 'SF' },
53
+ ],
54
+ value = ['MTL' , 'SF' ],
55
+ multi = True ,
56
+ clearable = False
57
+ ),
58
+ html .Div (
59
+ id = 'dropdown-value' ,
60
+ style = {'height' : '10px' , 'width' : '10px' }
61
+ )
62
+ ])
63
+
64
+ @app .callback (
65
+ Output ('dropdown-value' , 'children' ),
66
+ [Input ('my-unclearable-dropdown' , 'value' )]
67
+ )
68
+ def update_value (val ):
69
+ return ', ' .join (val )
70
+
71
+ dash_duo .start_server (app )
72
+
73
+ dropdown = dash_duo .find_element ('#my-unclearable-dropdown input' )
74
+ dropdown .send_keys (Keys .BACKSPACE )
75
+ dropdown .send_keys (Keys .BACKSPACE )
76
+ dash_duo .find_element ('#dropdown-value' ).click ()
77
+
78
+ assert len (dash_duo .find_element ('#dropdown-value' ).text ) > 0
You can’t perform that action at this time.
0 commit comments