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

Commit 4d2b27a

Browse files
authored
Fix broken threads list timestamp layout (#9922)
* Add option to show full identifier as tooltip on sender profiles * Show full user id as tooltip on threads list entries * Fix broken threads list timestamp layout Previously, thread list timestamps would overflow into the unread messages bubble on the right. This is fixed by resetting the width of the timestamp and ensuring both the timestamp and the display name can shrink if necessary. Both now also use ellipses if necessary.
1 parent 6d354e3 commit 4d2b27a

File tree

5 files changed

+40
-15
lines changed

5 files changed

+40
-15
lines changed

res/css/views/rooms/_EventTile.pcss

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ $left-gutter: 64px;
884884

885885
&::before {
886886
inset: 0;
887+
pointer-events: none; /* ensures the title for the sender name can be correctly displayed */
887888
}
888889

889890
/* Display notification dot */
@@ -927,8 +928,14 @@ $left-gutter: 64px;
927928
inset: $padding auto auto $padding;
928929
}
929930

931+
.mx_EventTile_details {
932+
overflow: hidden;
933+
}
934+
930935
.mx_DisambiguatedProfile {
931936
display: inline-flex;
937+
align-items: center;
938+
flex: 1;
932939

933940
.mx_DisambiguatedProfile_displayName,
934941
.mx_DisambiguatedProfile_mxid {
@@ -979,7 +986,9 @@ $left-gutter: 64px;
979986

980987
.mx_MessageTimestamp {
981988
font-size: $font-12px;
982-
max-width: var(--MessageTimestamp-max-width);
989+
width: unset; /* Cancel the default width */
990+
overflow: hidden; /* ensure correct overflow behavior */
991+
text-overflow: ellipsis;
983992
position: initial;
984993
margin-left: auto; /* to ensure it's end-aligned even if it's the only element of its parent */
985994
}

src/components/views/messages/DisambiguatedProfile.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright 2021 Šimon Brandner <[email protected]>
3-
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
Copyright 2022-2023 The Matrix.org Foundation C.I.C.
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import React from "react";
1919
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
2020
import classNames from "classnames";
2121

22+
import { _t } from "../../../languageHandler";
2223
import { getUserNameColorClass } from "../../../utils/FormattingUtils";
2324
import UserIdentifier from "../../../customisations/UserIdentifier";
2425

@@ -28,35 +29,44 @@ interface IProps {
2829
onClick?(): void;
2930
colored?: boolean;
3031
emphasizeDisplayName?: boolean;
32+
withTooltip?: boolean;
3133
}
3234

3335
export default class DisambiguatedProfile extends React.Component<IProps> {
3436
public render(): JSX.Element {
35-
const { fallbackName, member, colored, emphasizeDisplayName, onClick } = this.props;
37+
const { fallbackName, member, colored, emphasizeDisplayName, withTooltip, onClick } = this.props;
3638
const rawDisplayName = member?.rawDisplayName || fallbackName;
3739
const mxid = member?.userId;
3840

39-
let colorClass;
41+
let colorClass: string | undefined;
4042
if (colored) {
4143
colorClass = getUserNameColorClass(fallbackName);
4244
}
4345

4446
let mxidElement;
45-
if (member?.disambiguate && mxid) {
46-
mxidElement = (
47-
<span className="mx_DisambiguatedProfile_mxid">
48-
{UserIdentifier.getDisplayUserIdentifier(mxid, { withDisplayName: true, roomId: member.roomId })}
49-
</span>
50-
);
47+
let title: string | undefined;
48+
49+
if (mxid) {
50+
const identifier =
51+
UserIdentifier.getDisplayUserIdentifier?.(mxid, {
52+
withDisplayName: true,
53+
roomId: member.roomId,
54+
}) ?? mxid;
55+
if (member?.disambiguate) {
56+
mxidElement = <span className="mx_DisambiguatedProfile_mxid">{identifier}</span>;
57+
}
58+
title = _t("%(displayName)s (%(matrixId)s)", {
59+
displayName: rawDisplayName,
60+
matrixId: identifier,
61+
});
5162
}
5263

53-
const displayNameClasses = classNames({
64+
const displayNameClasses = classNames(colorClass, {
5465
mx_DisambiguatedProfile_displayName: emphasizeDisplayName,
55-
[colorClass]: true,
5666
});
5767

5868
return (
59-
<div className="mx_DisambiguatedProfile" onClick={onClick}>
69+
<div className="mx_DisambiguatedProfile" title={withTooltip ? title : undefined} onClick={onClick}>
6070
<span className={displayNameClasses} dir="auto">
6171
{rawDisplayName}
6272
</span>

src/components/views/messages/SenderProfile.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
Copyright 2023 The Matrix.org Foundation C.I.C.
23
Copyright 2015, 2016 OpenMarket Ltd
34
45
Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,9 +25,10 @@ import { useRoomMemberProfile } from "../../../hooks/room/useRoomMemberProfile";
2425
interface IProps {
2526
mxEvent: MatrixEvent;
2627
onClick?(): void;
28+
withTooltip?: boolean;
2729
}
2830

29-
export default function SenderProfile({ mxEvent, onClick }: IProps): JSX.Element {
31+
export default function SenderProfile({ mxEvent, onClick, withTooltip }: IProps): JSX.Element {
3032
const member = useRoomMemberProfile({
3133
userId: mxEvent.getSender(),
3234
member: mxEvent.sender,
@@ -39,6 +41,7 @@ export default function SenderProfile({ mxEvent, onClick }: IProps): JSX.Element
3941
member={member}
4042
colored={true}
4143
emphasizeDisplayName={true}
44+
withTooltip={withTooltip}
4245
/>
4346
) : null;
4447
}

src/components/views/rooms/EventTile.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2015 - 2022 The Matrix.org Foundation C.I.C.
2+
Copyright 2015 - 2023 The Matrix.org Foundation C.I.C.
33
Copyright 2019 Michael Telatynski <[email protected]>
44
55
Licensed under the Apache License, Version 2.0 (the "License");
@@ -1091,6 +1091,8 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
10911091
this.context.timelineRenderingType === TimelineRenderingType.Thread
10921092
) {
10931093
sender = <SenderProfile onClick={this.onSenderProfileClick} mxEvent={this.props.mxEvent} />;
1094+
} else if (this.context.timelineRenderingType === TimelineRenderingType.ThreadsList) {
1095+
sender = <SenderProfile mxEvent={this.props.mxEvent} withTooltip />;
10941096
} else {
10951097
sender = <SenderProfile mxEvent={this.props.mxEvent} />;
10961098
}

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,7 @@
23162316
"Last month": "Last month",
23172317
"The beginning of the room": "The beginning of the room",
23182318
"Jump to date": "Jump to date",
2319+
"%(displayName)s (%(matrixId)s)": "%(displayName)s (%(matrixId)s)",
23192320
"Downloading": "Downloading",
23202321
"Decrypting": "Decrypting",
23212322
"Download": "Download",

0 commit comments

Comments
 (0)