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

Commit ed5c02b

Browse files
authored
Fix long room address and name not being clipped on room info card and update _RoomSummaryCard.pcss (#10811)
* Handle a long room address and name with ellipsis on RoomSummaryCard * Use a class selector for maintainability Sort the selectors
1 parent 739eec8 commit ed5c02b

File tree

4 files changed

+51
-11
lines changed

4 files changed

+51
-11
lines changed

cypress/e2e/right-panel/right-panel.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@ import { HomeserverInstance } from "../../plugins/utils/homeserver";
2020
import Chainable = Cypress.Chainable;
2121

2222
const ROOM_NAME = "Test room";
23+
const ROOM_NAME_LONG =
24+
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore " +
25+
"et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +
26+
"aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " +
27+
"dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui " +
28+
"officia deserunt mollit anim id est laborum.";
2329
const SPACE_NAME = "Test space";
2430
const NAME = "Alice";
31+
const ROOM_ADDRESS_LONG =
32+
"loremIpsumDolorSitAmetConsecteturAdipisicingElitSedDoEiusmodTemporIncididuntUtLaboreEtDoloreMagnaAliqua";
2533

2634
const getMemberTileByName = (name: string): Chainable<JQuery<HTMLElement>> => {
2735
return cy.get(`.mx_EntityTile, [title="${name}"]`);
@@ -58,6 +66,31 @@ describe("RightPanel", () => {
5866
});
5967

6068
describe("in rooms", () => {
69+
it("should handle long room address and long room name", () => {
70+
cy.createRoom({ name: ROOM_NAME_LONG });
71+
viewRoomSummaryByName(ROOM_NAME_LONG);
72+
73+
cy.openRoomSettings();
74+
75+
// Set a local room address
76+
cy.findByTestId("local-address-fieldset").within(() => {
77+
cy.get(".mx_AliasSettings_localAddresses").click();
78+
cy.findByLabelText("Room address").type(ROOM_ADDRESS_LONG);
79+
cy.findByRole("button", { name: "Add" }).click();
80+
});
81+
82+
cy.closeDialog();
83+
84+
// Close and reopen the right panel to render the room address
85+
cy.findByRole("button", { name: "Room info" }).click();
86+
cy.get(".mx_RightPanel").should("not.exist");
87+
cy.findByRole("button", { name: "Room info" }).click();
88+
89+
cy.get(".mx_RightPanel").percySnapshotElement("RoomSummaryCard - with a room name and a local address", {
90+
widths: [264], // Emulate the UI. The value is based on minWidth specified on MainSplit.tsx
91+
});
92+
});
93+
6194
it("should handle clicking add widgets", () => {
6295
viewRoomSummaryByName(ROOM_NAME);
6396

res/css/views/right_panel/_RoomSummaryCard.pcss

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ limitations under the License.
1919
text-align: center;
2020
margin-top: $spacing-20;
2121

22-
h1 {
22+
.mx_RoomSummaryCard_roomName,
23+
.mx_RoomSummaryCard_alias {
24+
display: -webkit-box;
25+
-webkit-line-clamp: 2;
26+
-webkit-box-orient: vertical;
27+
white-space: pre-wrap;
28+
overflow: hidden;
29+
}
30+
31+
.mx_RoomSummaryCard_roomName {
2332
margin: $spacing-12 0 $spacing-4;
2433
font-weight: var(--font-semi-bold);
2534
}
2635

2736
.mx_RoomSummaryCard_alias {
2837
font-size: $font-13px;
2938
color: $secondary-content;
30-
overflow: hidden;
3139
text-overflow: ellipsis;
3240
}
3341

34-
h1,
35-
.mx_RoomSummaryCard_alias {
36-
display: -webkit-box;
37-
-webkit-line-clamp: 2;
38-
-webkit-box-orient: vertical;
39-
white-space: pre-wrap;
40-
}
41-
4242
.mx_RoomSummaryCard_avatar {
4343
display: inline-flex;
4444

src/components/views/right_panel/RoomSummaryCard.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,13 @@ const RoomSummaryCard: React.FC<IProps> = ({ room, permalinkCreator, onClose })
318318
/>
319319
</div>
320320

321-
<RoomName room={room}>{(name) => <h1 title={name}>{name}</h1>}</RoomName>
321+
<RoomName room={room}>
322+
{(name) => (
323+
<h1 className="mx_RoomSummaryCard_roomName" title={name}>
324+
{name}
325+
</h1>
326+
)}
327+
</RoomName>
322328
<div className="mx_RoomSummaryCard_alias" title={alias}>
323329
{alias}
324330
</div>

test/components/views/right_panel/__snapshots__/RoomSummaryCard-test.tsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ exports[`<RoomSummaryCard /> renders the room summary 1`] = `
4646
/>
4747
</div>
4848
<h1
49+
class="mx_RoomSummaryCard_roomName"
4950
title="!room:domain.org"
5051
>
5152
!room:domain.org

0 commit comments

Comments
 (0)