File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ class SplitButton extends React.Component {
1414 onClick,
1515 target,
1616 href,
17+ toggleLabel,
1718 bsSize,
1819 bsStyle,
1920 ...props } = this . props ;
@@ -37,7 +38,7 @@ class SplitButton extends React.Component {
3738 { title }
3839 </ Button >
3940 < SplitToggle
40- aria-label = { title }
41+ aria-label = { toggleLabel || title }
4142 bsStyle = { bsStyle }
4243 bsSize = { bsSize }
4344 disabled = { disabled }
@@ -63,7 +64,11 @@ SplitButton.propTypes = {
6364 /**
6465 * The content of the split button.
6566 */
66- title : React . PropTypes . node . isRequired
67+ title : React . PropTypes . node . isRequired ,
68+ /**
69+ * Accessible label for the toggle; the value of `title` if not specified.
70+ */
71+ toggleLabel : React . PropTypes . string
6772} ;
6873
6974SplitButton . defaultProps = {
Original file line number Diff line number Diff line change @@ -101,4 +101,21 @@ describe('SplitButton', () => {
101101 assert . equal ( linkElement . target , '_blank' ) ;
102102 } ) ;
103103
104+ it ( 'should set aria-label on toggle from title' , ( ) => {
105+ const instance = ReactTestUtils . renderIntoDocument ( simple ) ;
106+
107+ const toggleNode = ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'dropdown-toggle' ) ;
108+ expect ( toggleNode . getAttribute ( 'aria-label' ) ) . to . equal ( 'Title' ) ;
109+ } ) ;
110+
111+ it ( 'should set aria-label on toggle from toggleLabel' , ( ) => {
112+ const instance = ReactTestUtils . renderIntoDocument (
113+ < SplitButton title = 'Title' id = 'test-id' toggleLabel = 'Label' >
114+ < MenuItem > Item 1</ MenuItem >
115+ </ SplitButton >
116+ ) ;
117+
118+ const toggleNode = ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'dropdown-toggle' ) ;
119+ expect ( toggleNode . getAttribute ( 'aria-label' ) ) . to . equal ( 'Label' ) ;
120+ } ) ;
104121} ) ;
You can’t perform that action at this time.
0 commit comments