From 466f37a83d4001ca044382243a7d713dfdfb83df Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 8 Jul 2024 12:52:26 +0100 Subject: [PATCH] Improve new room header accessibility (#12725) * Fix room header topic not showing on keyboard navigation whilst still using tabstops Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix keyboard activation of the room header FacePile Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix label on room header facepile Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Comment Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update src/components/views/elements/FacePile.tsx Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- res/css/views/rooms/_RoomHeader.pcss | 15 +++++++++------ src/components/views/elements/FacePile.tsx | 17 +++++++++-------- src/components/views/rooms/RoomHeader.tsx | 17 +++++++---------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/res/css/views/rooms/_RoomHeader.pcss b/res/css/views/rooms/_RoomHeader.pcss index 6a25ea7943..2af5e5ca10 100644 --- a/res/css/views/rooms/_RoomHeader.pcss +++ b/res/css/views/rooms/_RoomHeader.pcss @@ -74,14 +74,17 @@ limitations under the License. } } -.mx_RoomHeader:hover .mx_RoomHeader_topic { - /* height needed to compute the transition, it equals to the `line-height` +.mx_RoomHeader:hover, +.mx_RoomHeader:focus-within { + .mx_RoomHeader_topic { + /* height needed to compute the transition, it equals to the `line-height` value in pixels */ - height: calc($font-13px * 1.5); - opacity: 1; + height: calc($font-13px * 1.5); + opacity: 1; - a:hover { - text-decoration: underline; + a:hover { + text-decoration: underline; + } } } diff --git a/src/components/views/elements/FacePile.tsx b/src/components/views/elements/FacePile.tsx index 67c11e2f35..d459040f0b 100644 --- a/src/components/views/elements/FacePile.tsx +++ b/src/components/views/elements/FacePile.tsx @@ -21,7 +21,7 @@ import { AvatarStack, Tooltip } from "@vector-im/compound-web"; import MemberAvatar from "../avatars/MemberAvatar"; import AccessibleButton, { ButtonEvent } from "./AccessibleButton"; -interface IProps extends HTMLAttributes { +interface IProps extends Omit, "onChange"> { members: RoomMember[]; size: string; overflow: boolean; @@ -32,6 +32,11 @@ interface IProps extends HTMLAttributes { onClick?: (e: ButtonEvent) => void | Promise; } +/** + * A component which displays a list of avatars in a row, with a tooltip showing the names of the users. + * + * Any additional props, not named explicitly here, are passed to the underlying {@link AccessibleButton}. + */ const FacePile: FC = ({ members, size, @@ -40,6 +45,7 @@ const FacePile: FC = ({ tooltipShortcut, children, viewUserOnClick = true, + onClick, ...props }) => { const faces = members.map( @@ -47,12 +53,7 @@ const FacePile: FC = ({ ? (m) => : (m) => ( - + ), ); @@ -65,7 +66,7 @@ const FacePile: FC = ({ ); const content = ( - + {pileContents} {children} diff --git a/src/components/views/rooms/RoomHeader.tsx b/src/components/views/rooms/RoomHeader.tsx index d37ff18a76..6f4620b637 100644 --- a/src/components/views/rooms/RoomHeader.tsx +++ b/src/components/views/rooms/RoomHeader.tsx @@ -55,6 +55,7 @@ import { RoomKnocksBar } from "./RoomKnocksBar"; import { isVideoRoom } from "../../../utils/video-rooms"; import { notificationLevelToIndicator } from "../../../utils/notifications"; import { CallGuestLinkButton } from "./RoomHeader/CallGuestLinkButton"; +import { ButtonEvent } from "../elements/AccessibleButton"; export default function RoomHeader({ room, @@ -364,16 +365,7 @@ export default function RoomHeader({ )} {!isDirectMessage && ( - { - RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList); - e.stopPropagation(); - }} - > + { + RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList); + e.stopPropagation(); + }} + aria-label={_t("common|n_members", { count: memberCount })} > {formatCount(memberCount)}