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

Improve new room header accessibility #12725

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions res/css/views/rooms/_RoomHeader.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
17 changes: 9 additions & 8 deletions src/components/views/elements/FacePile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLSpanElement> {
interface IProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
members: RoomMember[];
size: string;
overflow: boolean;
Expand All @@ -32,6 +32,11 @@ interface IProps extends HTMLAttributes<HTMLSpanElement> {
onClick?: (e: ButtonEvent) => void | Promise<void>;
}

/**
* 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<IProps> = ({
members,
size,
Expand All @@ -40,19 +45,15 @@ const FacePile: FC<IProps> = ({
tooltipShortcut,
children,
viewUserOnClick = true,
onClick,
...props
}) => {
const faces = members.map(
tooltipLabel
? (m) => <MemberAvatar key={m.userId} member={m} size={size} hideTitle />
: (m) => (
<Tooltip key={m.userId} label={m.name} caption={tooltipShortcut}>
<MemberAvatar
member={m}
size={size}
viewUserOnClick={!props.onClick && viewUserOnClick}
hideTitle
/>
<MemberAvatar member={m} size={size} viewUserOnClick={!onClick && viewUserOnClick} hideTitle />
</Tooltip>
),
);
Expand All @@ -65,7 +66,7 @@ const FacePile: FC<IProps> = ({
);

const content = (
<AccessibleButton className="mx_FacePile" onClick={props.onClick ?? null}>
<AccessibleButton {...props} className="mx_FacePile" onClick={onClick ?? null}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the ?? null required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes because undefined != null, AccessibleButton does not accept undefined

<AvatarStack>{pileContents}</AvatarStack>
{children}
</AccessibleButton>
Expand Down
17 changes: 7 additions & 10 deletions src/components/views/rooms/RoomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -364,23 +365,19 @@ export default function RoomHeader({
)}
</Flex>
{!isDirectMessage && (
<BodyText
as="div"
size="sm"
weight="medium"
aria-label={_t("common|n_members", { count: memberCount })}
onClick={(e: React.MouseEvent) => {
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList);
e.stopPropagation();
}}
>
<BodyText as="div" size="sm" weight="medium">
<FacePile
className="mx_RoomHeader_members"
members={members.slice(0, 3)}
size="20px"
overflow={false}
viewUserOnClick={false}
tooltipLabel={_t("room|header_face_pile_tooltip")}
onClick={(e: ButtonEvent) => {
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList);
e.stopPropagation();
}}
aria-label={_t("common|n_members", { count: memberCount })}
>
{formatCount(memberCount)}
</FacePile>
Expand Down
Loading