Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3587 from matrix-org/t3chguy/a11y_message_actions…
Browse files Browse the repository at this point in the history
…_bar

Improve A11Y of timeline. Show timestamp & Actions on focus-within
  • Loading branch information
t3chguy authored Nov 4, 2019
2 parents b3a64bb + 6d3b563 commit 92ee50f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
7 changes: 6 additions & 1 deletion res/css/views/rooms/_EventTile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ limitations under the License.
// Explicit relationships so that it doesn't apply to nested EventTile components (e.g in Replies)
.mx_EventTile_last > div > a > .mx_MessageTimestamp,
.mx_EventTile:hover > div > a > .mx_MessageTimestamp,
.mx_EventTile:focus-within > div > a > .mx_MessageTimestamp,
.mx_EventTile.mx_EventTile_actionBarFocused > div > a > .mx_MessageTimestamp {
visibility: visible;
}

.mx_EventTile:hover .mx_MessageActionBar,
.mx_EventTile:focus-within .mx_MessageActionBar,
.mx_EventTile.mx_EventTile_actionBarFocused .mx_MessageActionBar {
visibility: visible;
}
Expand All @@ -166,6 +168,7 @@ limitations under the License.
}

.mx_EventTile:hover .mx_EventTile_line,
.mx_EventTile:focus-within .mx_EventTile_line,
.mx_EventTile.mx_EventTile_actionBarFocused .mx_EventTile_line {
background-color: $event-selected-color;
}
Expand Down Expand Up @@ -465,7 +468,8 @@ div.mx_EventTile_notSent.mx_EventTile_redacted .mx_UnknownBody {
}
}

.mx_EventTile:hover .mx_EventTile_body pre {
.mx_EventTile:hover .mx_EventTile_body pre,
.mx_EventTile:focus-within .mx_EventTile_body pre {
border: 1px solid #e5e5e5; // deliberate constant as we're behind an invert filter
}

Expand All @@ -487,6 +491,7 @@ div.mx_EventTile_notSent.mx_EventTile_redacted .mx_UnknownBody {
background-image: url($copy-button-url);
}

.mx_EventTile_body .mx_EventTile_pre_container:focus-within .mx_EventTile_copyButton,
.mx_EventTile_body .mx_EventTile_pre_container:hover .mx_EventTile_copyButton {
visibility: visible;
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/messages/DateSeparator.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export default class DateSeparator extends React.Component {

render() {
// ARIA treats <hr/>s as separators, here we abuse them slightly so manually treat this entire thing as one
return <h2 className="mx_DateSeparator" role="separator">
// tab-index=-1 to allow it to be focusable but do not add tab stop for it, primarily for screen readers
return <h2 className="mx_DateSeparator" role="separator" tabIndex={-1}>
<hr role="none" />
<div>{ this.getLabel() }</div>
<hr role="none" />
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/messages/MessageActionBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export default class MessageActionBar extends React.PureComponent {
/>;
}

return <div className="mx_MessageActionBar">
// aria-live=off to not have this read out automatically as navigating around timeline, gets repetitive.
return <div className="mx_MessageActionBar" role="toolbar" aria-label={_t("Message Actions")} aria-live="off">
{reactButton}
{replyButton}
{editButton}
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/messages/MessageTimestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class MessageTimestamp extends React.Component {
render() {
const date = new Date(this.props.ts);
return (
<span className="mx_MessageTimestamp" title={formatFullDate(date, this.props.showTwelveHour)}>
<span className="mx_MessageTimestamp" title={formatFullDate(date, this.props.showTwelveHour)} aria-hidden={true}>
{ formatTime(date, this.props.showTwelveHour) }
</span>
);
Expand Down
10 changes: 8 additions & 2 deletions src/components/views/rooms/EventTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const TextForEvent = require('../../../TextForEvent');
import dis from '../../../dispatcher';
import SettingsStore from "../../../settings/SettingsStore";
import {EventStatus, MatrixClient} from 'matrix-js-sdk';
import {formatTime} from "../../../DateUtils";

const ObjectUtils = require('../../../ObjectUtils');

Expand Down Expand Up @@ -786,14 +787,19 @@ module.exports = createReactClass({
this.props.permalinkCreator,
'replyThread',
);
// tab-index=-1 to allow it to be focusable but do not add tab stop for it, primarily for screen readers
return (
<div className={classes}>
<div className={classes} tabIndex={-1}>
<div className="mx_EventTile_msgOption">
{ readAvatars }
</div>
{ sender }
<div className="mx_EventTile_line">
<a href={permalink} onClick={this.onPermalinkClicked}>
<a
href={permalink}
onClick={this.onPermalinkClicked}
aria-label={formatTime(new Date(this.props.mxEvent.getTs()), this.props.isTwelveHour)}
>
{ timestamp }
</a>
{ this._renderE2EPadlock() }
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@
"React": "React",
"Reply": "Reply",
"Edit": "Edit",
"Message Actions": "Message Actions",
"Options": "Options",
"Attachment": "Attachment",
"Error decrypting attachment": "Error decrypting attachment",
Expand Down

0 comments on commit 92ee50f

Please sign in to comment.