@@ -37,7 +37,6 @@ class SLDSNotification extends React.Component {
3737 constructor ( props ) {
3838 super ( props ) ;
3939 this . state = {
40- isOpen : this . props . isOpen ,
4140 interval : null ,
4241 revealForScreenreader : false ,
4342 } ;
@@ -47,24 +46,25 @@ class SLDSNotification extends React.Component {
4746 if ( this . props . duration ) {
4847 const that = this ;
4948 setTimeout ( function ( ) {
50- that . setState ( { isOpen : false } ) ;
49+ this . onDismiss ( ) ;
5150 } , that . props . duration ) ;
5251 }
5352 }
5453
5554 componentWillUnmount ( ) {
56- this . setState ( { interval : null } ) ;
55+ this . setState ( {
56+ interval : null
57+ } ) ;
5758 }
5859
5960 componentWillReceiveProps ( nextProps ) {
6061 if ( this . props . isOpen !== nextProps . isOpen ) {
61- this . setState ( { isOpen : nextProps . isOpen } ) ;
6262 if ( nextProps . isOpen && ! this . state . interval ) {
6363 this . setState ( { interval : setTimeout ( ( ) => {
64- this . setState ( { revealForScreenreader : ! this . state . revealForScreenreader } ) ;
65- console . log ( 'the isOpen state inside is' , this . state . isOpen ) ;
64+ this . setState ( { revealForScreenreader : true } ) ;
6665 } , 500 ) } )
6766 }
67+ console . log ( 'revealForScreen' , this . state . revealForScreenreader ) ;
6868 }
6969 }
7070
@@ -104,7 +104,10 @@ class SLDSNotification extends React.Component {
104104
105105 onDismiss ( ) {
106106 if ( this . props . onDismiss ) this . props . onDismiss ( ) ;
107- this . setState ( { isOpen : false } ) ;
107+ this . setState ( {
108+ revealForScreenreader : false ,
109+ interval : null ,
110+ } ) ;
108111 }
109112
110113 renderAlertContent ( ) {
@@ -161,7 +164,7 @@ class SLDSNotification extends React.Component {
161164 }
162165
163166 render ( ) {
164- if ( this . state . isOpen ) {
167+ if ( this . props . isOpen ) {
165168 return (
166169 < div className = "slds-notify-container" >
167170 < div ref = "alertContent" className = { this . getClassName ( ) } role = "alert" >
0 commit comments