File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ const Select = props => {
14
14
html_size,
15
15
valid,
16
16
invalid,
17
+ value,
17
18
...otherProps
18
19
} = props ;
19
20
@@ -41,6 +42,7 @@ const Select = props => {
41
42
onChange = { handleChange }
42
43
className = { class_name || className }
43
44
htmlSize = { html_size }
45
+ value = { value || '' }
44
46
>
45
47
< option value = "" disabled hidden >
46
48
{ props . placeholder }
Original file line number Diff line number Diff line change @@ -43,6 +43,23 @@ describe('Select', () => {
43
43
expect ( select ) . not . toHaveValue ( ) ;
44
44
} ) ;
45
45
46
+ test ( 'null will clear value' , ( ) => {
47
+ const {
48
+ container : { firstChild : select }
49
+ } = render (
50
+ < Select
51
+ id = "test-select"
52
+ options = { [
53
+ { label : 'Item 1' , value : '1' } ,
54
+ { label : 'Item 2' , value : '2' }
55
+ ] }
56
+ value = { null }
57
+ />
58
+ ) ;
59
+
60
+ expect ( select ) . not . toHaveValue ( ) ;
61
+ } ) ;
62
+
46
63
test ( 'sets validity using "valid" and "invalid" props' , ( ) => {
47
64
const validSelect = render ( < Select valid /> ) ;
48
65
const invalidSelect = render ( < Select invalid /> ) ;
You can’t perform that action at this time.
0 commit comments