From 54fa9a572e1c0eb256b341134ba41083af22727e Mon Sep 17 00:00:00 2001 From: Manan Sadana Date: Fri, 6 Oct 2023 12:24:25 +0530 Subject: [PATCH] Fix: Clicking on members pile does nothing. (#11657) * Fix: Clicking on pile opens members list * onClick used on Accessible Component * Updated snapshots for testing * Snapshots updated after merging --------- Co-authored-by: Manan Sadana --- res/css/structures/_SpaceRoomView.pcss | 1 + src/components/views/elements/FacePile.tsx | 8 ++++-- .../views/elements/RoomFacePile.tsx | 2 ++ .../__snapshots__/FacePile-test.tsx.snap | 26 ++++++++++++------- .../__snapshots__/RoomFacePile-test.tsx.snap | 26 ++++++++++++------- 5 files changed, 41 insertions(+), 22 deletions(-) diff --git a/res/css/structures/_SpaceRoomView.pcss b/res/css/structures/_SpaceRoomView.pcss index a4a4aa7884..000781bd97 100644 --- a/res/css/structures/_SpaceRoomView.pcss +++ b/res/css/structures/_SpaceRoomView.pcss @@ -189,6 +189,7 @@ limitations under the License. .mx_FacePile { display: inline-block; + cursor: pointer; } .mx_SpaceRoomView_landing_inviteButton, diff --git a/src/components/views/elements/FacePile.tsx b/src/components/views/elements/FacePile.tsx index d7570fdfa7..5c76219965 100644 --- a/src/components/views/elements/FacePile.tsx +++ b/src/components/views/elements/FacePile.tsx @@ -19,6 +19,7 @@ import { RoomMember } from "matrix-js-sdk/src/matrix"; import { AvatarStack, Tooltip } from "@vector-im/compound-web"; import MemberAvatar from "../avatars/MemberAvatar"; +import AccessibleButton, { ButtonEvent } from "./AccessibleButton"; interface IProps extends HTMLAttributes { members: RoomMember[]; @@ -28,6 +29,7 @@ interface IProps extends HTMLAttributes { tooltipShortcut?: string; children?: ReactNode; viewUserOnClick?: boolean; + onClick?: (e: ButtonEvent) => void | Promise; } const FacePile: FC = ({ @@ -64,8 +66,10 @@ const FacePile: FC = ({ const content = (
- {pileContents} - {children} + + {pileContents} + {children} +
); diff --git a/src/components/views/elements/RoomFacePile.tsx b/src/components/views/elements/RoomFacePile.tsx index 68d9348c45..6ec333c4e5 100644 --- a/src/components/views/elements/RoomFacePile.tsx +++ b/src/components/views/elements/RoomFacePile.tsx @@ -23,6 +23,7 @@ import DMRoomMap from "../../../utils/DMRoomMap"; import FacePile from "./FacePile"; import { useRoomMembers } from "../../../hooks/useRoomMembers"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; +import { ButtonEvent } from "./AccessibleButton"; const DEFAULT_NUM_FACES = 5; @@ -32,6 +33,7 @@ interface IProps extends HTMLAttributes { room: Room; onlyKnownUsers?: boolean; numShown?: number; + onClick?: (e: ButtonEvent) => void | Promise; } const RoomFacePile: FC = ({ room, onlyKnownUsers = true, numShown = DEFAULT_NUM_FACES, ...props }) => { diff --git a/test/components/views/elements/__snapshots__/FacePile-test.tsx.snap b/test/components/views/elements/__snapshots__/FacePile-test.tsx.snap index 731a5f460f..6c2b64cc15 100644 --- a/test/components/views/elements/__snapshots__/FacePile-test.tsx.snap +++ b/test/components/views/elements/__snapshots__/FacePile-test.tsx.snap @@ -7,18 +7,24 @@ exports[` renders with a tooltip 1`] = ` data-state="closed" >
- - 4 - + + 4 + +
diff --git a/test/components/views/elements/__snapshots__/RoomFacePile-test.tsx.snap b/test/components/views/elements/__snapshots__/RoomFacePile-test.tsx.snap index 26fea36a98..11056fad01 100644 --- a/test/components/views/elements/__snapshots__/RoomFacePile-test.tsx.snap +++ b/test/components/views/elements/__snapshots__/RoomFacePile-test.tsx.snap @@ -7,18 +7,24 @@ exports[` renders 1`] = ` data-state="closed" >
- - b - + + b + +