File tree Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -277,6 +277,7 @@ class AjaxUploader extends Component<UploadProps> {
277
277
openFileDialogOnClick,
278
278
onMouseEnter,
279
279
onMouseLeave,
280
+ hasControlInside,
280
281
...otherProps
281
282
} = this . props ;
282
283
const cls = clsx ( {
@@ -297,10 +298,10 @@ class AjaxUploader extends Component<UploadProps> {
297
298
onMouseLeave,
298
299
onDrop : this . onFileDrop ,
299
300
onDragOver : this . onFileDrop ,
300
- tabIndex : '0' ,
301
+ tabIndex : hasControlInside ? undefined : '0' ,
301
302
} ;
302
303
return (
303
- < Tag { ...events } className = { cls } role = " button" style = { style } >
304
+ < Tag { ...events } className = { cls } role = { hasControlInside ? undefined : ' button' } style = { style } >
304
305
< input
305
306
{ ...pickAttrs ( otherProps , { aria : true , data : true } ) }
306
307
id = { id }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class Upload extends Component<UploadProps> {
21
21
customRequest : null ,
22
22
withCredentials : false ,
23
23
openFileDialogOnClick : true ,
24
+ hasControlInside : false ,
24
25
} ;
25
26
26
27
private uploader : AjaxUpload ;
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export interface UploadProps
43
43
styles ?: {
44
44
input ?: React . CSSProperties ;
45
45
} ;
46
+ hasControlInside ?: boolean ;
46
47
}
47
48
48
49
export interface UploadProgressEvent extends Partial < ProgressEvent > {
Original file line number Diff line number Diff line change @@ -865,4 +865,18 @@ describe('uploader', () => {
865
865
expect ( wrapper . find ( '.bamboo-input' ) . props ( ) . style . color ) . toEqual ( 'red' ) ;
866
866
expect ( wrapper . find ( 'input' ) . props ( ) . style . display ) . toBe ( 'none' ) ;
867
867
} ) ;
868
+
869
+ it ( 'Should be focusable and has role=button by default' , ( ) => {
870
+ const wrapper = mount ( < Uploader /> ) ;
871
+
872
+ expect ( wrapper . find ( 'span' ) . props ( ) . tabIndex ) . toBe ( '0' ) ;
873
+ expect ( wrapper . find ( 'span' ) . props ( ) . role ) . toBe ( 'button' ) ;
874
+ } ) ;
875
+
876
+ it ( "Should not be focusable and doesn't have role=button with hasControlInside=true" , ( ) => {
877
+ const wrapper = mount ( < Uploader hasControlInside /> ) ;
878
+
879
+ expect ( wrapper . find ( 'span' ) . props ( ) . tabIndex ) . toBe ( undefined ) ;
880
+ expect ( wrapper . find ( 'span' ) . props ( ) . role ) . toBe ( undefined ) ;
881
+ } ) ;
868
882
} ) ;
You can’t perform that action at this time.
0 commit comments