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

Commit 43ffd89

Browse files
authored
Fix accessibility issues around the room list and space panel (#10717)
* Fix room sublist group label being read twice in Orca * Fix room list sublist notification badges always having a tab stop
1 parent c824c4a commit 43ffd89

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/components/views/rooms/NotificationBadge.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interface IClickableProps extends IProps, React.InputHTMLAttributes<Element> {
4444
/**
4545
* If specified will return an AccessibleButton instead of a div.
4646
*/
47-
onClick?(ev: React.MouseEvent): void;
47+
onClick(ev: React.MouseEvent): void;
4848
}
4949

5050
interface IState {
@@ -112,7 +112,7 @@ export default class NotificationBadge extends React.PureComponent<XOR<IProps, I
112112

113113
public render(): ReactNode {
114114
/* eslint @typescript-eslint/no-unused-vars: ["error", { "ignoreRestSiblings": true }] */
115-
const { notification, showUnsentTooltip, forceCount, onClick } = this.props;
115+
const { notification, showUnsentTooltip, forceCount, onClick, tabIndex } = this.props;
116116

117117
if (notification.isIdle) return null;
118118
if (forceCount) {
@@ -135,6 +135,7 @@ export default class NotificationBadge extends React.PureComponent<XOR<IProps, I
135135
onClick={onClick}
136136
onMouseOver={this.onMouseOver}
137137
onMouseLeave={this.onMouseLeave}
138+
tabIndex={tabIndex}
138139
>
139140
{tooltip}
140141
</StatelessNotificationBadge>

src/components/views/rooms/NotificationBadge/StatelessNotificationBadge.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,32 @@ import { formatCount } from "../../../../utils/FormattingUtils";
2121
import AccessibleButton from "../../elements/AccessibleButton";
2222
import { NotificationColor } from "../../../../stores/notifications/NotificationColor";
2323
import { useSettingValue } from "../../../../hooks/useSettings";
24+
import { XOR } from "../../../../@types/common";
2425

2526
interface Props {
2627
symbol: string | null;
2728
count: number;
2829
color: NotificationColor;
29-
onClick?: (ev: MouseEvent) => void;
3030
onMouseOver?: (ev: MouseEvent) => void;
3131
onMouseLeave?: (ev: MouseEvent) => void;
3232
children?: ReactNode;
3333
label?: string;
3434
}
3535

36-
export function StatelessNotificationBadge({ symbol, count, color, ...props }: Props): JSX.Element {
36+
interface ClickableProps extends Props {
37+
/**
38+
* If specified will return an AccessibleButton instead of a div.
39+
*/
40+
onClick(ev: React.MouseEvent): void;
41+
tabIndex?: number;
42+
}
43+
44+
export function StatelessNotificationBadge({
45+
symbol,
46+
count,
47+
color,
48+
...props
49+
}: XOR<Props, ClickableProps>): JSX.Element {
3750
const hideBold = useSettingValue("feature_hidebold");
3851

3952
// Don't show a badge if we don't need to

src/components/views/rooms/RoomSublist.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ interface IProps {
8585
onListCollapse?: (isExpanded: boolean) => void;
8686
}
8787

88+
function getLabelId(tagId: TagID): string {
89+
return `mx_RoomSublist_label_${tagId}`;
90+
}
91+
8892
// TODO: Use re-resizer's NumberSize when it is exposed as the type
8993
interface ResizeDelta {
9094
width: number;
@@ -712,7 +716,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
712716
title={this.props.isMinimized ? this.props.label : undefined}
713717
>
714718
<span className={collapseClasses} />
715-
<span>{this.props.label}</span>
719+
<span id={getLabelId(this.props.tagId)}>{this.props.label}</span>
716720
</Button>
717721
{this.renderMenu()}
718722
{this.props.isMinimized ? null : badgeContainer}
@@ -880,7 +884,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
880884
className={classes}
881885
role="group"
882886
aria-hidden={hidden}
883-
aria-label={this.props.label}
887+
aria-labelledby={getLabelId(this.props.tagId)}
884888
onKeyDown={this.onKeyDown}
885889
>
886890
{this.renderHeader()}

0 commit comments

Comments
 (0)