@@ -107,37 +107,44 @@ export class Button extends Component<ButtonProps, {}> {
107107 / ^ ( x - s m a l l | s m a l l ) $ / . test ( size || '' ) && / ^ i c o n - / . test ( type || '' ) ,
108108 } ) ;
109109
110- return (
111- /* eslint-disable react/button-has-type */
112- < span
113- className = 'react-slds-button-focus-wrapper'
114- style = { { outline : 0 } }
115- tabIndex = { - 1 }
110+ const buttonContent = (
111+ // eslint-disable-next-line react/button-has-type
112+ < button
113+ ref = { ( node : HTMLButtonElement ) => {
114+ this . node = node ;
115+ if ( buttonRef ) buttonRef ( node ) ;
116+ } }
117+ className = { btnClassNames }
118+ type = { htmlType }
119+ { ...props }
120+ onClick = { this . onClick }
116121 >
117- < button
118- ref = { ( node : HTMLButtonElement ) => {
119- this . node = node ;
120- if ( buttonRef ) buttonRef ( node ) ;
121- } }
122- className = { btnClassNames }
123- type = { htmlType }
124- { ...props }
125- onClick = { this . onClick }
126- >
127- { icon && iconAlign !== 'right'
128- ? this . renderIcon ( iconSize , inverse )
129- : null }
130- { children || label }
131- { icon && iconAlign === 'right'
132- ? this . renderIcon ( iconSize , inverse )
133- : null }
134- { iconMore ? this . renderIconMore ( ) : null }
135- { alt ? < span className = 'slds-assistive-text' > { alt } </ span > : null }
136- { loading ? < Spinner /> : null }
137- </ button >
138- </ span >
139- /* eslint-enable react/button-has-type */
122+ { icon && iconAlign !== 'right'
123+ ? this . renderIcon ( iconSize , inverse )
124+ : null }
125+ { children || label }
126+ { icon && iconAlign === 'right'
127+ ? this . renderIcon ( iconSize , inverse )
128+ : null }
129+ { iconMore ? this . renderIconMore ( ) : null }
130+ { alt ? < span className = 'slds-assistive-text' > { alt } </ span > : null }
131+ { loading ? < Spinner /> : null }
132+ </ button >
140133 ) ;
134+
135+ if ( props . tabIndex != null ) {
136+ return (
137+ < span
138+ className = 'react-slds-button-focus-wrapper'
139+ style = { { outline : 0 } }
140+ tabIndex = { - 1 }
141+ >
142+ { buttonContent }
143+ </ span >
144+ ) ;
145+ }
146+
147+ return buttonContent ;
141148 }
142149}
143150
0 commit comments