Merge pull request #3499 from matrix-org/t3chguy/accessibility2
Accessibility fixes to the LeftPanel
This commit is contained in:
commit
891eb7af3f
7 changed files with 45 additions and 15 deletions
|
@ -58,7 +58,17 @@ export const KeyCode = {
|
||||||
KEY_X: 88,
|
KEY_X: 88,
|
||||||
KEY_Y: 89,
|
KEY_Y: 89,
|
||||||
KEY_Z: 90,
|
KEY_Z: 90,
|
||||||
KEY_BACKTICK: 223,
|
KEY_BACKTICK: 223, // DO NOT USE THIS: browsers disagree on backtick 192 vs 223
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Key = {
|
||||||
|
HOME: "Home",
|
||||||
|
End: "End",
|
||||||
|
PAGE_UP: "PageUp",
|
||||||
|
PAGE_DOWN: "PageDown",
|
||||||
|
BACKTICK: "`",
|
||||||
|
|
||||||
|
K: "k",
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isOnlyCtrlOrCmdKeyEvent(ev) {
|
export function isOnlyCtrlOrCmdKeyEvent(ev) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import createReactClass from 'create-react-class';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { DragDropContext } from 'react-beautiful-dnd';
|
import { DragDropContext } from 'react-beautiful-dnd';
|
||||||
|
|
||||||
import { KeyCode, isOnlyCtrlOrCmdKeyEvent } from '../../Keyboard';
|
import { Key, isOnlyCtrlOrCmdKeyEvent } from '../../Keyboard';
|
||||||
import PageTypes from '../../PageTypes';
|
import PageTypes from '../../PageTypes';
|
||||||
import CallMediaHandler from '../../CallMediaHandler';
|
import CallMediaHandler from '../../CallMediaHandler';
|
||||||
import { fixupColorFonts } from '../../utils/FontManager';
|
import { fixupColorFonts } from '../../utils/FontManager';
|
||||||
|
@ -353,23 +353,23 @@ const LoggedInView = createReactClass({
|
||||||
const hasModifier = ev.altKey || ev.ctrlKey || ev.metaKey || ev.shiftKey ||
|
const hasModifier = ev.altKey || ev.ctrlKey || ev.metaKey || ev.shiftKey ||
|
||||||
ev.key === "Alt" || ev.key === "Control" || ev.key === "Meta" || ev.key === "Shift";
|
ev.key === "Alt" || ev.key === "Control" || ev.key === "Meta" || ev.key === "Shift";
|
||||||
|
|
||||||
switch (ev.keyCode) {
|
switch (ev.key) {
|
||||||
case KeyCode.PAGE_UP:
|
case Key.PAGE_UP:
|
||||||
case KeyCode.PAGE_DOWN:
|
case Key.PAGE_DOWN:
|
||||||
if (!hasModifier) {
|
if (!hasModifier) {
|
||||||
this._onScrollKeyPressed(ev);
|
this._onScrollKeyPressed(ev);
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyCode.HOME:
|
case Key.HOME:
|
||||||
case KeyCode.END:
|
case Key.END:
|
||||||
if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
|
if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
|
||||||
this._onScrollKeyPressed(ev);
|
this._onScrollKeyPressed(ev);
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyCode.KEY_K:
|
case Key.K:
|
||||||
if (ctrlCmdOnly) {
|
if (ctrlCmdOnly) {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'focus_room_filter',
|
action: 'focus_room_filter',
|
||||||
|
@ -377,7 +377,9 @@ const LoggedInView = createReactClass({
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyCode.KEY_BACKTICK:
|
case Key.BACKTICK:
|
||||||
|
if (ev.key !== "`") break;
|
||||||
|
|
||||||
// Ideally this would be CTRL+P for "Profile", but that's
|
// Ideally this would be CTRL+P for "Profile", but that's
|
||||||
// taken by the print dialog. CTRL+I for "Information"
|
// taken by the print dialog. CTRL+I for "Information"
|
||||||
// was previously chosen but conflicted with italics in
|
// was previously chosen but conflicted with italics in
|
||||||
|
|
|
@ -307,11 +307,11 @@ const RoomSubList = createReactClass({
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isCollapsed) {
|
if (isCollapsed) {
|
||||||
return <div ref="subList" className={subListClasses}>
|
return <div ref="subList" className={subListClasses} role="group" aria-label={this.props.label}>
|
||||||
{this._getHeaderJsx(isCollapsed)}
|
{this._getHeaderJsx(isCollapsed)}
|
||||||
</div>;
|
</div>;
|
||||||
} else if (this._canUseLazyListRendering()) {
|
} else if (this._canUseLazyListRendering()) {
|
||||||
return <div ref="subList" className={subListClasses}>
|
return <div ref="subList" className={subListClasses} role="group" aria-label={this.props.label}>
|
||||||
{this._getHeaderJsx(isCollapsed)}
|
{this._getHeaderJsx(isCollapsed)}
|
||||||
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
|
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
|
||||||
<LazyRenderList
|
<LazyRenderList
|
||||||
|
@ -325,7 +325,7 @@ const RoomSubList = createReactClass({
|
||||||
} else {
|
} else {
|
||||||
const roomTiles = this.props.list.map(r => this.makeRoomTile(r));
|
const roomTiles = this.props.list.map(r => this.makeRoomTile(r));
|
||||||
const tiles = roomTiles.concat(this.props.extraTiles);
|
const tiles = roomTiles.concat(this.props.extraTiles);
|
||||||
return <div ref="subList" className={subListClasses}>
|
return <div ref="subList" className={subListClasses} role="group" aria-label={this.props.label}>
|
||||||
{this._getHeaderJsx(isCollapsed)}
|
{this._getHeaderJsx(isCollapsed)}
|
||||||
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
|
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
|
||||||
{ tiles }
|
{ tiles }
|
||||||
|
@ -340,7 +340,7 @@ const RoomSubList = createReactClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref="subList" className="mx_RoomSubList">
|
<div ref="subList" className="mx_RoomSubList" role="group" aria-label={this.props.label}>
|
||||||
{ this._getHeaderJsx(isCollapsed) }
|
{ this._getHeaderJsx(isCollapsed) }
|
||||||
{ content }
|
{ content }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default function AccessibleButton(props) {
|
||||||
delete restProps.inputRef;
|
delete restProps.inputRef;
|
||||||
|
|
||||||
restProps.tabIndex = restProps.tabIndex || "0";
|
restProps.tabIndex = restProps.tabIndex || "0";
|
||||||
restProps.role = "button";
|
restProps.role = restProps.role || "button";
|
||||||
restProps.className = (restProps.className ? restProps.className + " " : "") + "mx_AccessibleButton";
|
restProps.className = (restProps.className ? restProps.className + " " : "") + "mx_AccessibleButton";
|
||||||
|
|
||||||
if (kind) {
|
if (kind) {
|
||||||
|
|
|
@ -805,7 +805,7 @@ module.exports = createReactClass({
|
||||||
const subListComponents = this._mapSubListProps(subLists);
|
const subListComponents = this._mapSubListProps(subLists);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={this._collectResizeContainer} className="mx_RoomList"
|
<div ref={this._collectResizeContainer} className="mx_RoomList" role="listbox" aria-label={_t("Rooms")}
|
||||||
onMouseMove={this.onMouseMove} onMouseLeave={this.onMouseLeave}>
|
onMouseMove={this.onMouseMove} onMouseLeave={this.onMouseLeave}>
|
||||||
{ subListComponents }
|
{ subListComponents }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -33,6 +33,7 @@ import AccessibleButton from '../elements/AccessibleButton';
|
||||||
import ActiveRoomObserver from '../../../ActiveRoomObserver';
|
import ActiveRoomObserver from '../../../ActiveRoomObserver';
|
||||||
import RoomViewStore from '../../../stores/RoomViewStore';
|
import RoomViewStore from '../../../stores/RoomViewStore';
|
||||||
import SettingsStore from "../../../settings/SettingsStore";
|
import SettingsStore from "../../../settings/SettingsStore";
|
||||||
|
import {_t} from "../../../languageHandler";
|
||||||
|
|
||||||
module.exports = createReactClass({
|
module.exports = createReactClass({
|
||||||
displayName: 'RoomTile',
|
displayName: 'RoomTile',
|
||||||
|
@ -368,6 +369,8 @@ module.exports = createReactClass({
|
||||||
|
|
||||||
const RoomAvatar = sdk.getComponent('avatars.RoomAvatar');
|
const RoomAvatar = sdk.getComponent('avatars.RoomAvatar');
|
||||||
|
|
||||||
|
let ariaLabel = name;
|
||||||
|
|
||||||
let dmIndicator;
|
let dmIndicator;
|
||||||
if (this._isDirectMessageRoom(this.props.room.roomId)) {
|
if (this._isDirectMessageRoom(this.props.room.roomId)) {
|
||||||
dmIndicator = <img
|
dmIndicator = <img
|
||||||
|
@ -379,12 +382,24 @@ module.exports = createReactClass({
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (notifBadges && mentionBadges && !isInvite) {
|
||||||
|
ariaLabel += " " + _t("It has %(count)s unread messages including mentions.", {
|
||||||
|
count: notificationCount,
|
||||||
|
});
|
||||||
|
} else if (notifBadges) {
|
||||||
|
ariaLabel += " " + _t("It has %(count)s unread messages.", { count: notificationCount });
|
||||||
|
} else if (mentionBadges && !isInvite) {
|
||||||
|
ariaLabel += " " + _t("It has unread mentions.");
|
||||||
|
}
|
||||||
|
|
||||||
return <AccessibleButton tabIndex="0"
|
return <AccessibleButton tabIndex="0"
|
||||||
className={classes}
|
className={classes}
|
||||||
onClick={this.onClick}
|
onClick={this.onClick}
|
||||||
onMouseEnter={this.onMouseEnter}
|
onMouseEnter={this.onMouseEnter}
|
||||||
onMouseLeave={this.onMouseLeave}
|
onMouseLeave={this.onMouseLeave}
|
||||||
onContextMenu={this.onContextMenu}
|
onContextMenu={this.onContextMenu}
|
||||||
|
aria-label={ariaLabel}
|
||||||
|
role="option"
|
||||||
>
|
>
|
||||||
<div className={avatarClasses}>
|
<div className={avatarClasses}>
|
||||||
<div className="mx_RoomTile_avatar_container">
|
<div className="mx_RoomTile_avatar_container">
|
||||||
|
|
|
@ -949,6 +949,9 @@
|
||||||
"Securely back up your keys to avoid losing them. <a>Learn more.</a>": "Securely back up your keys to avoid losing them. <a>Learn more.</a>",
|
"Securely back up your keys to avoid losing them. <a>Learn more.</a>": "Securely back up your keys to avoid losing them. <a>Learn more.</a>",
|
||||||
"Not now": "Not now",
|
"Not now": "Not now",
|
||||||
"Don't ask me again": "Don't ask me again",
|
"Don't ask me again": "Don't ask me again",
|
||||||
|
"It has %(count)s unread messages including mentions.|other": "It has %(count)s unread messages including mentions.",
|
||||||
|
"It has %(count)s unread messages.|other": "It has %(count)s unread messages.",
|
||||||
|
"It has unread mentions.": "It has unread mentions.",
|
||||||
"Add a topic": "Add a topic",
|
"Add a topic": "Add a topic",
|
||||||
"Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.": "Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.",
|
"Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.": "Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.",
|
||||||
"This room has already been upgraded.": "This room has already been upgraded.",
|
"This room has already been upgraded.": "This room has already been upgraded.",
|
||||||
|
|
Loading…
Reference in a new issue