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

Commit

Permalink
Change aria-label to aria-labelledby, make listitem tab-able, overrid…
Browse files Browse the repository at this point in the history
…e the profile picture alt text
  • Loading branch information
akirk committed Mar 8, 2024
1 parent e30354b commit 4bf8d18
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/components/views/avatars/MemberAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function MemberAvatar(
return (
<BaseAvatar
{...props}
tabindex="-1"

Check failure on line 89 in src/components/views/avatars/MemberAvatar.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Type '{ tabindex: string; size: string; name: string; title: string | undefined; idName: string | undefined; url: string | null | undefined; onClick: ((ev: ButtonEvent) => void) | undefined; ... 10 more ...; urls?: string[] | undefined; }' is not assignable to type 'IntrinsicAttributes & IProps & RefAttributes<HTMLElement>'.
size={size}
name={name ?? ""}
title={hideTitle ? undefined : title}
Expand All @@ -102,6 +103,7 @@ function MemberAvatar(
}
: props.onClick
}
aria-label={name ? name + ". " : ""}
altText={_t("common|user_avatar")}
ref={ref}
/>
Expand Down
7 changes: 4 additions & 3 deletions src/components/views/messages/TextualBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
}

let widgets;
const id = 'mx_EventTile_content_' + mxEvent.getId();
if (this.state.links.length && !this.state.widgetHidden && this.props.showUrlPreview) {
widgets = (
<LinkPreviewGroup
Expand All @@ -636,7 +637,7 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {

if (isEmote) {
return (
<div className="mx_MEmoteBody mx_EventTile_content" onClick={this.onBodyLinkClick}>
<div className="mx_MEmoteBody mx_EventTile_content" id={id} onClick={this.onBodyLinkClick}>
*&nbsp;
<span className="mx_MEmoteBody_sender" onClick={this.onEmoteSenderClick}>
{mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender()}
Expand All @@ -649,14 +650,14 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
}
if (isNotice) {
return (
<div className="mx_MNoticeBody mx_EventTile_content" onClick={this.onBodyLinkClick}>
<div className="mx_MNoticeBody mx_EventTile_content" id={id} onClick={this.onBodyLinkClick}>
{body}
{widgets}
</div>
);
}
return (
<div className="mx_MTextBody mx_EventTile_content" onClick={this.onBodyLinkClick}>
<div className="mx_MTextBody mx_EventTile_content" id={id} onClick={this.onBodyLinkClick}>
{body}
{widgets}
</div>
Expand Down
15 changes: 9 additions & 6 deletions src/components/views/rooms/EventTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
this.context.timelineRenderingType,
);
avatar = (
<div className="mx_EventTile_avatar">
<div className="mx_EventTile_avatar" id={'mx_EventTile_avatar_'+this.props.mxEvent.getId()} tabindex="-1">

Check failure on line 1064 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Unknown property 'tabindex' found, use 'tabIndex' instead

Check failure on line 1064 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Type '{ children: Element; className: string; id: string; tabindex: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
<MemberAvatar
member={member}
size={avatarSize}
Expand Down Expand Up @@ -1147,6 +1147,7 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
<a
href={permalink}
onClick={this.onPermalinkClicked}
tabindex="-1"

Check failure on line 1150 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Unknown property 'tabindex' found, use 'tabIndex' instead

Check failure on line 1150 in src/components/views/rooms/EventTile.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Type '{ children: Element | null; href: string; onClick: (e: MouseEvent<Element, MouseEvent>) => void; tabindex: string; "aria-label": string; onContextMenu: (ev: MouseEvent<...>) => void; }' is not assignable to type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
aria-label={formatTime(new Date(this.props.mxEvent.getTs()), this.props.isTwelveHour)}
onContextMenu={this.onTimestampContextMenu}
>
Expand Down Expand Up @@ -1209,8 +1210,9 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
{
"ref": this.ref,
"className": classes,
"tabindex": 0,
"aria-live": ariaLive,
"aria-label": this.props.mxEvent.sender.name + '. ' + (this.props.mxEvent.clearEvent || this.props.mxEvent.event).content.body,
"aria-labelledby": `mx_EventTile_avatar_${this.props.mxEvent.getId()} mx_EventTile_content_${this.props.mxEvent.getId()}`,
"aria-atomic": true,
"data-scroll-tokens": scrollToken,
"data-has-reply": !!replyChain,
Expand Down Expand Up @@ -1264,8 +1266,9 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
{
"ref": this.ref,
"className": classes,
"tabIndex": -1,
"tabindex": 0,
"aria-live": ariaLive,
"aria-labelledby": `mx_EventTile_avatar_${this.props.mxEvent.getId()} mx_EventTile_content_${this.props.mxEvent.getId()}`,
"aria-atomic": "true",
"data-scroll-tokens": scrollToken,
"data-layout": this.props.layout,
Expand Down Expand Up @@ -1398,9 +1401,9 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
{
"ref": this.ref,
"className": classes,
"tabIndex": -1,
"tabindex": 0,
"aria-live": ariaLive,
"aria-label": this.props.mxEvent.sender.name + '. ' + (this.props.mxEvent.clearEvent || this.props.mxEvent.event).content.body,
"aria-labelledby": `mx_EventTile_avatar_${this.props.mxEvent.getId()} mx_EventTile_content_${this.props.mxEvent.getId()}`,
"aria-atomic": "true",
"data-scroll-tokens": scrollToken,
"data-layout": this.props.layout,
Expand All @@ -1415,7 +1418,7 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
{sender}
{ircPadlock}
{avatar}
<div className={lineClasses} key="mx_EventTile_line" onContextMenu={this.onContextMenu}>
<div className={lineClasses} key="mx_EventTile_line" onContextMenu={this.onContextMenu} aria-labelledby={'mx_EventTile_content_' + this.props.mxEvent.getId()}>
{this.renderContextMenu()}
{groupTimestamp}
{groupPadlock}
Expand Down

0 comments on commit 4bf8d18

Please sign in to comment.