@@ -39,7 +39,6 @@ class Button extends React.Component {
39
39
40
40
getClassName ( ) {
41
41
let isStateful = this . props . stateful && this . state . active ? true : false ;
42
-
43
42
return classNames ( this . props . className , 'slds-button' , {
44
43
[ `slds-button--${ this . props . variant } ` ] : this . props . variant ,
45
44
[ 'slds-is-selected' ] : isStateful ,
@@ -61,8 +60,8 @@ class Button extends React.Component {
61
60
render ( ) {
62
61
const props = omit ( 'className' , this . props ) ;
63
62
const click = createChainedFunction ( this . props . onClick , this . onClick . bind ( this ) ) ;
64
- const labelClasses = this . props . variant === 'icon' ? 'slds-assistive-text' : '' ;
65
63
64
+ //If the button is only an icon render this:
66
65
if ( this . props . variant === 'icon' ) {
67
66
return (
68
67
< button className = { this . getClassName ( ) } { ...props } onClick = { click } >
@@ -72,15 +71,19 @@ class Button extends React.Component {
72
71
className = { 'slds-icon' } />
73
72
< span className = "slds-assistive-text" > { this . props . label } </ span >
74
73
</ button >
75
- )
76
- } else {
74
+ ) ;
75
+ }
76
+ //Else we assume the button has a visible label (with or without an icon):
77
+ else {
77
78
return (
78
79
< button className = { this . getClassName ( ) } { ...props } onClick = { click } >
79
- { this . props . iconPosition === 'right' ? this . props . label : null }
80
+
81
+ < span aria-live = "assertive" > { this . props . iconPosition === 'right' ? this . props . label : null } </ span >
80
82
81
83
{ this . renderIcon ( ) }
82
84
83
- { ( this . props . iconPosition === 'left' || ! this . props . iconPosition ) ? this . props . label : null }
85
+ < span aria-live = "assertive" > { ( this . props . iconPosition === 'left' || ! this . props . iconPosition ) ? this . props . label : null } </ span >
86
+
84
87
</ button >
85
88
) ;
86
89
}
@@ -91,7 +94,7 @@ Button.propTypes = {
91
94
label : React . PropTypes . string . isRequired ,
92
95
variant : React . PropTypes . oneOf ( [ 'base' , 'neutral' , 'brand' , 'icon' ] ) ,
93
96
iconName : React . PropTypes . string ,
94
- iconSize : React . PropTypes . string ,
97
+ iconSize : React . PropTypes . oneOf ( [ 'x-small' , 'small' , 'medium' , 'large' ] ) ,
95
98
iconPosition : React . PropTypes . oneOf ( [ 'left' , 'right' ] ) ,
96
99
}
97
100
0 commit comments