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 => {
1414 html_size,
1515 valid,
1616 invalid,
17+ value,
1718 ...otherProps
1819 } = props ;
1920
@@ -41,6 +42,7 @@ const Select = props => {
4142 onChange = { handleChange }
4243 className = { class_name || className }
4344 htmlSize = { html_size }
45+ value = { value || '' }
4446 >
4547 < option value = "" disabled hidden >
4648 { props . placeholder }
Original file line number Diff line number Diff line change @@ -43,6 +43,23 @@ describe('Select', () => {
4343 expect ( select ) . not . toHaveValue ( ) ;
4444 } ) ;
4545
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+
4663 test ( 'sets validity using "valid" and "invalid" props' , ( ) => {
4764 const validSelect = render ( < Select valid /> ) ;
4865 const invalidSelect = render ( < Select invalid /> ) ;
You can’t perform that action at this time.
0 commit comments