Skip to content

Commit

Permalink
Conditionally enable aria-live region for the timeline scroll pannel
Browse files Browse the repository at this point in the history
(fixes element-hq/element-web#5696 and element-hq/element-web#5697)
We only wish to set aria-live to polite when the list is scrolled to the
bottom
to avoid flooding screen readers with loads of DOM changes when
scrolling
causing presentation of random message events.
To avoid presenting outgoing events twice we are only setting aria-live
when there is
a new content to add so e.g. style changes and similar won't be
propagated to assistive tools.
  • Loading branch information
pvagner committed May 28, 2018
1 parent 96ec3ab commit d533176
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/structures/ScrollPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,14 +680,20 @@ module.exports = React.createClass({

render: function() {
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
// We only wish to set aria-live to polite when the list is scrolled to the bottom
// to avoid flooding screen readers with loads of DOM changes when scrolling
// causing presentation of random message events.
// To avoid presenting outgoing events twice we are only setting aria-live when there is
// a new content to add so e.g. style changes and similar won't be propagated to assistive tools.
let enableLiveRegion = (this.scrollState.stuckAtBottom && this._pendingFillRequests['f']);
// TODO: the classnames on the div and ol could do with being updated to
// reflect the fact that we don't necessarily contain a list of messages.
// it's not obvious why we have a separate div and ol anyway.
return (<GeminiScrollbarWrapper autoshow={true} wrappedRef={this._collectGeminiScroll}
onScroll={this.onScroll} onResize={this.onResize}
className={this.props.className} style={this.props.style}>
<div className="mx_RoomView_messageListWrapper">
<ol ref="itemlist" className="mx_RoomView_MessageList" aria-live="polite">
<ol ref="itemlist" className="mx_RoomView_MessageList" aria-live={ enableLiveRegion ? "polite" : "off" }>
{ this.props.children }
</ol>
</div>
Expand Down

0 comments on commit d533176

Please sign in to comment.