File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 6161 "cross-env" : " ^7.0.2" ,
6262 "dumi" : " ^2.1.14" ,
6363 "eslint" : " ^7.0.0" ,
64- "father" : " ^4" ,
64+ "father" : " ^4.3.7 " ,
6565 "gh-pages" : " ^3.1.0" ,
6666 "husky" : " ^8.0.1" ,
6767 "less" : " ^3.10.3" ,
Original file line number Diff line number Diff line change @@ -57,8 +57,10 @@ export function resolveOnChange<
5757 target : { value : target } ,
5858 currentTarget : { value : target } ,
5959 } ) ;
60-
61- target . value = targetValue ;
60+ // https://github.com/ant-design/ant-design/issues/45737
61+ if ( target . type !== 'file' ) {
62+ target . value = targetValue ;
63+ }
6264 onChange ( event as React . ChangeEvent < E > ) ;
6365 return ;
6466 }
Original file line number Diff line number Diff line change @@ -79,6 +79,18 @@ describe('Input', () => {
7979 it ( 'support bigint type' , ( ) => {
8080 expect ( < Input value = { BigInt ( '2222' ) } /> ) . toBeTruthy ( ) ;
8181 } ) ;
82+
83+ it ( 'should be compatible with type="file"' , ( ) => {
84+ const onChange = jest . fn ( ) ;
85+ const { container } = render ( < Input type = "file" onChange = { onChange } /> ) ;
86+ const inputEl = container . querySelector ( 'input' ) ! ;
87+ const file = new File ( [ '(⌐□_□)' ] , 'file.xml' , { type : 'application/xml' } ) ;
88+ // upload the file by updating the value attribute of the input
89+ // I assume : <input type="file" data-testid="fileInput" />
90+ fireEvent . change ( inputEl , {
91+ target : { files : [ file ] } ,
92+ } ) ;
93+ } ) ;
8294} ) ;
8395
8496describe ( 'should support showCount' , ( ) => {
You can’t perform that action at this time.
0 commit comments