File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -364,7 +364,7 @@ class AjaxUploader extends Component<UploadProps> {
364364 ? { }
365365 : {
366366 onClick : openFileDialogOnClick ? this . onClick : ( ) => { } ,
367- onKeyDown : openFileDialogOnClick ? this . onKeyDown : ( ) => { } ,
367+ onKeyDown : openFileDialogOnClick && ! hasControlInside ? this . onKeyDown : ( ) => { } ,
368368 onMouseEnter,
369369 onMouseLeave,
370370 onDrop : this . onFileDrop ,
Original file line number Diff line number Diff line change @@ -1335,6 +1335,25 @@ describe('uploader', () => {
13351335 expect ( container . querySelector ( 'span' ) ! ) . not . toHaveAttribute ( 'role' , 'button' ) ;
13361336 } ) ;
13371337
1338+ it . each ( [ 'Enter' , ' ' ] ) ( 'Should leave %p activation to the child control' , key => {
1339+ const { container } = render (
1340+ < Upload hasControlInside >
1341+ < button type = "button" > Upload</ button >
1342+ </ Upload > ,
1343+ ) ;
1344+ const input = container . querySelector ( 'input' ) ! ;
1345+ const button = container . querySelector ( 'button' ) ! ;
1346+ const clickSpy = jest . spyOn ( input , 'click' ) . mockImplementation ( ( ) => { } ) ;
1347+
1348+ expect ( fireEvent . keyDown ( button , { key } ) ) . toBe ( true ) ;
1349+ expect ( clickSpy ) . not . toHaveBeenCalled ( ) ;
1350+
1351+ fireEvent . click ( button ) ;
1352+ expect ( clickSpy ) . toHaveBeenCalledTimes ( 1 ) ;
1353+
1354+ clickSpy . mockRestore ( ) ;
1355+ } ) ;
1356+
13381357 it ( "Should not be focusable and doesn't have role=button when click upload is disabled" , ( ) => {
13391358 const { container } = render ( < Upload openFileDialogOnClick = { false } /> ) ;
13401359
You can’t perform that action at this time.
0 commit comments