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

Commit 466f37a

Browse files
t3chguyrichvdh
andauthored
Improve new room header accessibility (#12725)
* Fix room header topic not showing on keyboard navigation whilst still using tabstops Signed-off-by: Michael Telatynski <[email protected]> * Fix keyboard activation of the room header FacePile Signed-off-by: Michael Telatynski <[email protected]> * Fix label on room header facepile Signed-off-by: Michael Telatynski <[email protected]> * Comment Signed-off-by: Michael Telatynski <[email protected]> * Update src/components/views/elements/FacePile.tsx Co-authored-by: Richard van der Hoff <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]> Co-authored-by: Richard van der Hoff <[email protected]>
1 parent b2a8915 commit 466f37a

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

res/css/views/rooms/_RoomHeader.pcss

+9-6
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,17 @@ limitations under the License.
7474
}
7575
}
7676

77-
.mx_RoomHeader:hover .mx_RoomHeader_topic {
78-
/* height needed to compute the transition, it equals to the `line-height`
77+
.mx_RoomHeader:hover,
78+
.mx_RoomHeader:focus-within {
79+
.mx_RoomHeader_topic {
80+
/* height needed to compute the transition, it equals to the `line-height`
7981
value in pixels */
80-
height: calc($font-13px * 1.5);
81-
opacity: 1;
82+
height: calc($font-13px * 1.5);
83+
opacity: 1;
8284

83-
a:hover {
84-
text-decoration: underline;
85+
a:hover {
86+
text-decoration: underline;
87+
}
8588
}
8689
}
8790

src/components/views/elements/FacePile.tsx

+9-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { AvatarStack, Tooltip } from "@vector-im/compound-web";
2121
import MemberAvatar from "../avatars/MemberAvatar";
2222
import AccessibleButton, { ButtonEvent } from "./AccessibleButton";
2323

24-
interface IProps extends HTMLAttributes<HTMLSpanElement> {
24+
interface IProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
2525
members: RoomMember[];
2626
size: string;
2727
overflow: boolean;
@@ -32,6 +32,11 @@ interface IProps extends HTMLAttributes<HTMLSpanElement> {
3232
onClick?: (e: ButtonEvent) => void | Promise<void>;
3333
}
3434

35+
/**
36+
* A component which displays a list of avatars in a row, with a tooltip showing the names of the users.
37+
*
38+
* Any additional props, not named explicitly here, are passed to the underlying {@link AccessibleButton}.
39+
*/
3540
const FacePile: FC<IProps> = ({
3641
members,
3742
size,
@@ -40,19 +45,15 @@ const FacePile: FC<IProps> = ({
4045
tooltipShortcut,
4146
children,
4247
viewUserOnClick = true,
48+
onClick,
4349
...props
4450
}) => {
4551
const faces = members.map(
4652
tooltipLabel
4753
? (m) => <MemberAvatar key={m.userId} member={m} size={size} hideTitle />
4854
: (m) => (
4955
<Tooltip key={m.userId} label={m.name} caption={tooltipShortcut}>
50-
<MemberAvatar
51-
member={m}
52-
size={size}
53-
viewUserOnClick={!props.onClick && viewUserOnClick}
54-
hideTitle
55-
/>
56+
<MemberAvatar member={m} size={size} viewUserOnClick={!onClick && viewUserOnClick} hideTitle />
5657
</Tooltip>
5758
),
5859
);
@@ -65,7 +66,7 @@ const FacePile: FC<IProps> = ({
6566
);
6667

6768
const content = (
68-
<AccessibleButton className="mx_FacePile" onClick={props.onClick ?? null}>
69+
<AccessibleButton {...props} className="mx_FacePile" onClick={onClick ?? null}>
6970
<AvatarStack>{pileContents}</AvatarStack>
7071
{children}
7172
</AccessibleButton>

src/components/views/rooms/RoomHeader.tsx

+7-10
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { RoomKnocksBar } from "./RoomKnocksBar";
5555
import { isVideoRoom } from "../../../utils/video-rooms";
5656
import { notificationLevelToIndicator } from "../../../utils/notifications";
5757
import { CallGuestLinkButton } from "./RoomHeader/CallGuestLinkButton";
58+
import { ButtonEvent } from "../elements/AccessibleButton";
5859

5960
export default function RoomHeader({
6061
room,
@@ -364,23 +365,19 @@ export default function RoomHeader({
364365
)}
365366
</Flex>
366367
{!isDirectMessage && (
367-
<BodyText
368-
as="div"
369-
size="sm"
370-
weight="medium"
371-
aria-label={_t("common|n_members", { count: memberCount })}
372-
onClick={(e: React.MouseEvent) => {
373-
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList);
374-
e.stopPropagation();
375-
}}
376-
>
368+
<BodyText as="div" size="sm" weight="medium">
377369
<FacePile
378370
className="mx_RoomHeader_members"
379371
members={members.slice(0, 3)}
380372
size="20px"
381373
overflow={false}
382374
viewUserOnClick={false}
383375
tooltipLabel={_t("room|header_face_pile_tooltip")}
376+
onClick={(e: ButtonEvent) => {
377+
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList);
378+
e.stopPropagation();
379+
}}
380+
aria-label={_t("common|n_members", { count: memberCount })}
384381
>
385382
{formatCount(memberCount)}
386383
</FacePile>

0 commit comments

Comments
 (0)