Skip to content

Commit 8db5df8

Browse files
committed
Make notification alert work with screenreader. Need to make transition smoother
1 parent d30c488 commit 8db5df8

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

components/SLDSNotification/index.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SLDSNotification extends React.Component {
3939
this.state = {
4040
isOpen: this.props.isOpen,
4141
interval: null,
42-
addSpace: false,
42+
revealForScreenreader: false,
4343
};
4444
}
4545

@@ -61,8 +61,8 @@ class SLDSNotification extends React.Component {
6161
this.setState({ isOpen: nextProps.isOpen });
6262
if(nextProps.isOpen && !this.state.interval){
6363
this.setState({interval: setTimeout(() => {
64-
this.setState({addSpace: !this.state.addSpace});
65-
}, 1000)})
64+
this.setState({revealForScreenreader: !this.state.revealForScreenreader});
65+
}, 500)})
6666
}
6767
}
6868
}
@@ -132,22 +132,31 @@ class SLDSNotification extends React.Component {
132132

133133
getClassName() {
134134
return classNames(this.props.className, "slds-notify", {
135+
[`slds-transition-hide`]: !this.state.revealForScreenreader,
135136
[`slds-notify--${this.props.variant}`]: this.props.variant,
136137
[`slds-theme--${this.props.theme}`]: this.props.theme,
137138
[`slds-theme--alert-texture-animated`]: this.props.texture,
138139
});
139140
}
140141

141142
renderContent() {
142-
return (
143-
<div>
144-
{this.state.addSpace ? " x" : ""}
143+
if(this.state.revealForScreenreader) {
144+
return (
145+
<div>
145146
<p ref="test" className="slds-assistive-text">{this.props.theme}</p>
146147
{this.renderClose()}
147148
{this.renderAlertContent()}
148149
{this.renderToastContent()}
149-
</div>
150-
)
150+
</div>
151+
)
152+
}
153+
else {
154+
return (
155+
<div className="slds-hidden">
156+
Notification loading
157+
</div>
158+
)
159+
}
151160
}
152161

153162
render(){

0 commit comments

Comments
 (0)