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

Settings A11Y tweaks #3475

Merged
merged 5 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/components/structures/TabbedView.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,19 @@ export class TabbedView extends React.Component {

const onClickHandler = () => this._setActiveTab(tab);

const label = _t(tab.label);
return (
<span className={classes} key={"tab_label_" + tab.label}
onClick={onClickHandler}>
<span
className={classes}
key={"tab_label_" + tab.label}
onClick={onClickHandler}
role="button"
aria-label={label}
tabIndex={0}
>
{tabIcon}
<span className="mx_TabbedView_tabLabel_text">
{_t(tab.label)}
{ label }
</span>
</span>
);
Expand Down
6 changes: 4 additions & 2 deletions src/components/views/dialogs/BaseDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { MatrixClient } from 'matrix-js-sdk';
import { KeyCode } from '../../../Keyboard';
import AccessibleButton from '../elements/AccessibleButton';
import MatrixClientPeg from '../../../MatrixClientPeg';
import { _t } from "../../../languageHandler";

/**
* Basic container for modal dialogs.
Expand Down Expand Up @@ -114,8 +115,9 @@ export default createReactClass({
render: function() {
let cancelButton;
if (this.props.hasCancel) {
cancelButton = <AccessibleButton onClick={this._onCancelClick} className="mx_Dialog_cancelButton">
</AccessibleButton>;
cancelButton = (
<AccessibleButton onClick={this._onCancelClick} className="mx_Dialog_cancelButton" aria-label={_t("Close dialog")} />
);
}

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/views/elements/AccessibleButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export default function AccessibleButton(props) {

restProps.tabIndex = restProps.tabIndex || "0";
restProps.role = "button";
restProps.className = (restProps.className ? restProps.className + " " : "") +
"mx_AccessibleButton";
restProps.className = (restProps.className ? restProps.className + " " : "") + "mx_AccessibleButton";

if (kind) {
// We apply a hasKind class to maintain backwards compatibility with
Expand All @@ -80,6 +79,7 @@ export default function AccessibleButton(props) {

if (disabled) {
restProps.className += " mx_AccessibleButton_disabled";
restProps["aria-disabled"] = true;
}

return React.createElement(element, restProps, children);
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/elements/LabelledToggleSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class LabelledToggleSwitch extends React.Component {

let firstPart = <span className="mx_SettingsFlag_label">{this.props.label}</span>;
let secondPart = <ToggleSwitch checked={this.props.value} disabled={this.props.disabled}
onChange={this.props.onChange} />;
onChange={this.props.onChange} aria-label={this.props.label} />;

if (this.props.toggleInFront) {
const temp = firstPart;
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/elements/SettingsFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = createReactClass({
return (
<div className="mx_SettingsFlag">
<span className="mx_SettingsFlag_label">{label}</span>
<ToggleSwitch checked={value} onChange={this.onChange} disabled={!canChange} />
<ToggleSwitch checked={value} onChange={this.onChange} disabled={!canChange} aria-label={label} />
</div>
);
},
Expand Down
13 changes: 12 additions & 1 deletion src/components/views/elements/ToggleSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,24 @@ export default class ToggleSwitch extends React.Component {
};

render() {
// eslint-disable-next-line no-unused-vars
const {checked, disabled, onChange, ...props} = this.props;

const classes = classNames({
"mx_ToggleSwitch": true,
"mx_ToggleSwitch_on": this.state.checked,
"mx_ToggleSwitch_enabled": !this.props.disabled,
});
return (
<div className={classes} onClick={this._onClick}>
<div
{...props}
className={classes}
onClick={this._onClick}
role="checkbox"
aria-checked={this.state.checked}
aria-disabled={disabled}
tabIndex={0}
>
<div className="mx_ToggleSwitch_ball" />
</div>
);
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 @@ -1211,6 +1211,7 @@
"Unable to find profiles for the Matrix IDs listed below - would you like to invite them anyway?": "Unable to find profiles for the Matrix IDs listed below - would you like to invite them anyway?",
"Invite anyway and never warn me again": "Invite anyway and never warn me again",
"Invite anyway": "Invite anyway",
"Close dialog": "Close dialog",
"Please tell us what went wrong or, better, create a GitHub issue that describes the problem.": "Please tell us what went wrong or, better, create a GitHub issue that describes the problem.",
"Preparing to send logs": "Preparing to send logs",
"Logs sent": "Logs sent",
Expand Down