This repository was archived by the owner on Jun 3, 2024. It is now read-only.
File tree 2 files changed +43
-2
lines changed
tests/integration/dropdown 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -75,15 +75,15 @@ export default class Dropdown extends Component {
75
75
onChange = { selectedOption => {
76
76
if ( multi ) {
77
77
let value ;
78
- if ( isNil ( selectedOption ) ) {
78
+ if ( isNil ( selectedOption ) && this . props . clearable ) {
79
79
value = [ ] ;
80
80
} else {
81
81
value = pluck ( 'value' , selectedOption ) ;
82
82
}
83
83
setProps ( { value} ) ;
84
84
} else {
85
85
let value ;
86
- if ( isNil ( selectedOption ) ) {
86
+ if ( isNil ( selectedOption ) && this . props . clearable ) {
87
87
value = null ;
88
88
} else {
89
89
value = selectedOption . value ;
Original file line number Diff line number Diff line change
1
+ import dash
2
+ from dash .dependencies import Input , Output
3
+ import dash_core_components as dcc
4
+ import dash_html_components as html
5
+
6
+ from selenium .webdriver .common .keys import Keys
7
+
8
+
9
+ def test_ddcf001_clearable_false_single (dash_duo ):
10
+ app = dash .Dash (__name__ )
11
+ app .layout = html .Div ([
12
+ dcc .Dropdown (
13
+ id = 'my-unclearable-dropdown' ,
14
+ options = [
15
+ {'label' : 'New York City' , 'value' : 'NYC' },
16
+ {'label' : 'Montreal' , 'value' : 'MTL' },
17
+ {'label' : 'San Francisco' , 'value' : 'SF' },
18
+ ],
19
+ value = 'MTL' ,
20
+ clearable = False
21
+ ),
22
+ html .Div (
23
+ id = 'dropdown-value' ,
24
+ style = {'height' : '10px' , 'width' : '10px' }
25
+ )
26
+ ])
27
+
28
+ @app .callback (
29
+ Output ('dropdown-value' , 'children' ),
30
+ [Input ('my-unclearable-dropdown' , 'value' )]
31
+ )
32
+ def update_value (val ):
33
+ return val
34
+
35
+ dash_duo .start_server (app )
36
+
37
+ dropdown = dash_duo .find_element ('#my-unclearable-dropdown input' )
38
+ dropdown .send_keys (Keys .BACKSPACE )
39
+ dash_duo .find_element ('#dropdown-value' ).click ()
40
+
41
+ assert len (dash_duo .find_element ('#dropdown-value' ).text ) > 0
You can’t perform that action at this time.
0 commit comments