Skip to content

Commit 96d78e7

Browse files
Germainnurjinjafar
Germain
authored andcommitted
Prevent event propagation when clicking icon buttons (matrix-org#11515)
* Prevent event propagation when clicking icon buttons * Inhibit view user on click behaviour for room header face pile * Update snapshot
1 parent 628e188 commit 96d78e7

File tree

3 files changed

+67
-35
lines changed

3 files changed

+67
-35
lines changed

src/components/views/elements/FacePile.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,30 @@ interface IProps extends HTMLAttributes<HTMLSpanElement> {
2727
tooltipLabel?: string;
2828
tooltipShortcut?: string;
2929
children?: ReactNode;
30+
viewUserOnClick?: boolean;
3031
}
3132

32-
const FacePile: FC<IProps> = ({ members, size, overflow, tooltipLabel, tooltipShortcut, children, ...props }) => {
33+
const FacePile: FC<IProps> = ({
34+
members,
35+
size,
36+
overflow,
37+
tooltipLabel,
38+
tooltipShortcut,
39+
children,
40+
viewUserOnClick = true,
41+
...props
42+
}) => {
3343
const faces = members.map(
3444
tooltipLabel
3545
? (m) => <MemberAvatar key={m.userId} member={m} size={size} hideTitle />
3646
: (m) => (
3747
<Tooltip key={m.userId} label={m.name} shortcut={tooltipShortcut}>
38-
<MemberAvatar member={m} size={size} viewUserOnClick={!props.onClick} hideTitle />
48+
<MemberAvatar
49+
member={m}
50+
size={size}
51+
viewUserOnClick={!props.onClick && viewUserOnClick}
52+
hideTitle
53+
/>
3954
</Tooltip>
4055
),
4156
);

src/components/views/rooms/RoomHeader.tsx

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -175,43 +175,55 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
175175
</Box>
176176
<Flex as="nav" align="center" gap="var(--cpd-space-2x)">
177177
{!useElementCallExclusively && (
178+
<Tooltip label={!voiceCallDisabledReason ? _t("Voice call") : voiceCallDisabledReason!}>
179+
<IconButton
180+
disabled={!!voiceCallDisabledReason}
181+
title={!voiceCallDisabledReason ? _t("Voice call") : voiceCallDisabledReason!}
182+
onClick={(evt) => {
183+
evt.stopPropagation();
184+
placeCall(room, CallType.Voice, voiceCallType);
185+
}}
186+
>
187+
<VoiceCallIcon />
188+
</IconButton>
189+
</Tooltip>
190+
)}
191+
<Tooltip label={!videoCallDisabledReason ? _t("Video call") : videoCallDisabledReason!}>
178192
<IconButton
179-
disabled={!!voiceCallDisabledReason}
180-
title={!voiceCallDisabledReason ? _t("Voice call") : voiceCallDisabledReason!}
181-
onClick={() => {
182-
placeCall(room, CallType.Voice, voiceCallType);
193+
disabled={!!videoCallDisabledReason}
194+
title={!videoCallDisabledReason ? _t("Video call") : videoCallDisabledReason!}
195+
onClick={(evt) => {
196+
evt.stopPropagation();
197+
placeCall(room, CallType.Video, videoCallType);
183198
}}
184199
>
185-
<VoiceCallIcon />
200+
<VideoCallIcon />
186201
</IconButton>
187-
)}
188-
<IconButton
189-
disabled={!!videoCallDisabledReason}
190-
title={!videoCallDisabledReason ? _t("Video call") : videoCallDisabledReason!}
191-
onClick={() => {
192-
placeCall(room, CallType.Video, videoCallType);
193-
}}
194-
>
195-
<VideoCallIcon />
196-
</IconButton>
197-
<IconButton
198-
indicator={notificationColorToIndicator(threadNotifications)}
199-
onClick={() => {
200-
showOrHidePanel(RightPanelPhases.ThreadPanel);
201-
}}
202-
title={_t("common|threads")}
203-
>
204-
<ThreadsIcon />
205-
</IconButton>
206-
<IconButton
207-
indicator={notificationColorToIndicator(globalNotificationState.color)}
208-
onClick={() => {
209-
showOrHidePanel(RightPanelPhases.NotificationPanel);
210-
}}
211-
title={_t("Notifications")}
212-
>
213-
<NotificationsIcon />
214-
</IconButton>
202+
</Tooltip>
203+
<Tooltip label={_t("common|threads")}>
204+
<IconButton
205+
indicator={notificationColorToIndicator(threadNotifications)}
206+
onClick={(evt) => {
207+
evt.stopPropagation();
208+
showOrHidePanel(RightPanelPhases.ThreadPanel);
209+
}}
210+
title={_t("common|threads")}
211+
>
212+
<ThreadsIcon />
213+
</IconButton>
214+
</Tooltip>
215+
<Tooltip label={_t("Notifications")}>
216+
<IconButton
217+
indicator={notificationColorToIndicator(globalNotificationState.color)}
218+
onClick={(evt) => {
219+
evt.stopPropagation();
220+
showOrHidePanel(RightPanelPhases.NotificationPanel);
221+
}}
222+
title={_t("Notifications")}
223+
>
224+
<NotificationsIcon />
225+
</IconButton>
226+
</Tooltip>
215227
</Flex>
216228
{!isDirectMessage && (
217229
<BodyText
@@ -229,6 +241,7 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
229241
members={members.slice(0, 3)}
230242
size="20px"
231243
overflow={false}
244+
viewUserOnClick={false}
232245
>
233246
{formatCount(memberCount)}
234247
</FacePile>

test/components/views/rooms/__snapshots__/RoomHeader-test.tsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ exports[`RoomHeader does not show the face pile for DMs 1`] = `
3737
>
3838
<button
3939
class="_icon-button_1k9cw_17"
40+
data-state="closed"
4041
disabled=""
4142
style="--cpd-icon-button-size: 32px;"
4243
title="There's no one here to call"
@@ -45,6 +46,7 @@ exports[`RoomHeader does not show the face pile for DMs 1`] = `
4546
</button>
4647
<button
4748
class="_icon-button_1k9cw_17"
49+
data-state="closed"
4850
disabled=""
4951
style="--cpd-icon-button-size: 32px;"
5052
title="There's no one here to call"
@@ -53,13 +55,15 @@ exports[`RoomHeader does not show the face pile for DMs 1`] = `
5355
</button>
5456
<button
5557
class="_icon-button_1k9cw_17"
58+
data-state="closed"
5659
style="--cpd-icon-button-size: 32px;"
5760
title="Threads"
5861
>
5962
<div />
6063
</button>
6164
<button
6265
class="_icon-button_1k9cw_17"
66+
data-state="closed"
6367
style="--cpd-icon-button-size: 32px;"
6468
title="Notifications"
6569
>

0 commit comments

Comments
 (0)