File tree Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Top Open diff view settings Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Top Open diff view settings Original file line number Diff line number Diff line change @@ -24,9 +24,20 @@ const Alert = React.createClass({
2424 < button
2525 type = "button"
2626 className = "close"
27- aria-label = { this . props . closeLabel }
27+ onClick = { this . props . onDismiss }
28+ aria-hidden = "true" >
29+ < span > ×</ span >
30+ </ button >
31+ ) ;
32+ } ,
33+
34+ renderSrOnlyDismissButton ( ) {
35+ return (
36+ < button
37+ type = "button"
38+ className = "close sr-only"
2839 onClick = { this . props . onDismiss } >
29- < span aria-hidden = "true" > × </ span >
40+ { this . props . closeLabel }
3041 </ button >
3142 ) ;
3243 } ,
@@ -41,6 +52,7 @@ const Alert = React.createClass({
4152 < div { ...this . props } role = "alert" className = { classNames ( this . props . className , classes ) } >
4253 { isDismissable ? this . renderDismissButton ( ) : null }
4354 { this . props . children }
55+ { isDismissable ? this . renderSrOnlyDismissButton ( ) : null }
4456 </ div >
4557 ) ;
4658 } ,
Original file line number Diff line number Diff line change @@ -81,16 +81,16 @@ describe('Alert', function () {
8181 assert . equal ( React . findDOMNode ( instance ) . getAttribute ( 'role' ) , 'alert' ) ;
8282 } ) ;
8383
84- it ( 'Should have add ARIAs to button' , function ( ) {
84+ it ( 'Should call onDismiss callback when the sr-only dismiss link is activated' , function ( done ) {
85+ let doneOp = function ( ) {
86+ done ( ) ;
87+ } ;
8588 let instance = ReactTestUtils . renderIntoDocument (
86- < Alert onDismiss = { ( ) => { } } closeLabel = 'close' > Message</ Alert >
89+ < Alert onDismiss = { doneOp } >
90+ Message
91+ </ Alert >
8792 ) ;
88-
89- let button = ReactTestUtils . findRenderedDOMComponentWithTag ( instance , 'button' ) ;
90-
91- assert . equal ( React . findDOMNode ( button ) . getAttribute ( 'aria-label' ) , 'close' ) ;
92- assert . equal ( React . findDOMNode ( button ) . children [ 0 ] . getAttribute ( 'aria-hidden' ) , 'true' ) ;
93+ ReactTestUtils . Simulate . click ( React . findDOMNode ( instance ) . getElementsByClassName ( 'sr-only' ) [ 0 ] ) ;
9394 } ) ;
94-
9595 } ) ;
9696} ) ;
You can’t perform that action at this time.
0 commit comments