File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,6 @@ const defaultProps = {
60
60
variant : 'primary' ,
61
61
active : false ,
62
62
disabled : false ,
63
- type : 'button' ,
64
63
} ;
65
64
66
65
const Button = React . forwardRef (
@@ -94,8 +93,10 @@ const Button = React.forwardRef(
94
93
props . ref = ref ;
95
94
}
96
95
97
- if ( ! as ) {
96
+ if ( type ) {
98
97
props . type = type ;
98
+ } else if ( ! as ) {
99
+ props . type = 'button' ;
99
100
}
100
101
101
102
const Component = as || 'button' ;
Original file line number Diff line number Diff line change @@ -26,6 +26,23 @@ describe('<Button>', () => {
26
26
. should . equal ( 'submit' ) ;
27
27
} ) ;
28
28
29
+ it ( 'Should show the type if explicitly passed in when "as" is used' , ( ) => {
30
+ mount (
31
+ < Button as = "div" type = "submit" >
32
+ Title
33
+ </ Button > ,
34
+ )
35
+ . getDOMNode ( )
36
+ . getAttribute ( 'type' )
37
+ . should . equal ( 'submit' ) ;
38
+ } ) ;
39
+
40
+ it ( 'Should not have default type=button when "as" is used' , ( ) => {
41
+ const wrapper = mount ( < Button as = "div" > Title</ Button > ) ;
42
+
43
+ expect ( wrapper . getDOMNode ( ) . getAttribute ( 'type' ) ) . to . be . null ;
44
+ } ) ;
45
+
29
46
it ( 'should forward refs to the button' , ( ) => {
30
47
const ref = React . createRef ( ) ;
31
48
mount (
You can’t perform that action at this time.
0 commit comments