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
This commit is contained in:
Suguru Hirahara 2023-05-09 07:56:09 +00:00 committed by GitHub
parent 739eec8555
commit ed5c02be6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 11 deletions

View file

@ -20,8 +20,16 @@ import { HomeserverInstance } from "../../plugins/utils/homeserver";
import Chainable = Cypress.Chainable; import Chainable = Cypress.Chainable;
const ROOM_NAME = "Test room"; const ROOM_NAME = "Test room";
const ROOM_NAME_LONG =
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore " +
"et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +
"aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " +
"dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui " +
"officia deserunt mollit anim id est laborum.";
const SPACE_NAME = "Test space"; const SPACE_NAME = "Test space";
const NAME = "Alice"; const NAME = "Alice";
const ROOM_ADDRESS_LONG =
"loremIpsumDolorSitAmetConsecteturAdipisicingElitSedDoEiusmodTemporIncididuntUtLaboreEtDoloreMagnaAliqua";
const getMemberTileByName = (name: string): Chainable<JQuery<HTMLElement>> => { const getMemberTileByName = (name: string): Chainable<JQuery<HTMLElement>> => {
return cy.get(`.mx_EntityTile, [title="${name}"]`); return cy.get(`.mx_EntityTile, [title="${name}"]`);
@ -58,6 +66,31 @@ describe("RightPanel", () => {
}); });
describe("in rooms", () => { describe("in rooms", () => {
it("should handle long room address and long room name", () => {
cy.createRoom({ name: ROOM_NAME_LONG });
viewRoomSummaryByName(ROOM_NAME_LONG);
cy.openRoomSettings();
// Set a local room address
cy.findByTestId("local-address-fieldset").within(() => {
cy.get(".mx_AliasSettings_localAddresses").click();
cy.findByLabelText("Room address").type(ROOM_ADDRESS_LONG);
cy.findByRole("button", { name: "Add" }).click();
});
cy.closeDialog();
// Close and reopen the right panel to render the room address
cy.findByRole("button", { name: "Room info" }).click();
cy.get(".mx_RightPanel").should("not.exist");
cy.findByRole("button", { name: "Room info" }).click();
cy.get(".mx_RightPanel").percySnapshotElement("RoomSummaryCard - with a room name and a local address", {
widths: [264], // Emulate the UI. The value is based on minWidth specified on MainSplit.tsx
});
});
it("should handle clicking add widgets", () => { it("should handle clicking add widgets", () => {
viewRoomSummaryByName(ROOM_NAME); viewRoomSummaryByName(ROOM_NAME);

View file

@ -19,7 +19,16 @@ limitations under the License.
text-align: center; text-align: center;
margin-top: $spacing-20; margin-top: $spacing-20;
h1 { .mx_RoomSummaryCard_roomName,
.mx_RoomSummaryCard_alias {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
white-space: pre-wrap;
overflow: hidden;
}
.mx_RoomSummaryCard_roomName {
margin: $spacing-12 0 $spacing-4; margin: $spacing-12 0 $spacing-4;
font-weight: var(--font-semi-bold); font-weight: var(--font-semi-bold);
} }
@ -27,18 +36,9 @@ limitations under the License.
.mx_RoomSummaryCard_alias { .mx_RoomSummaryCard_alias {
font-size: $font-13px; font-size: $font-13px;
color: $secondary-content; color: $secondary-content;
overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
h1,
.mx_RoomSummaryCard_alias {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
white-space: pre-wrap;
}
.mx_RoomSummaryCard_avatar { .mx_RoomSummaryCard_avatar {
display: inline-flex; display: inline-flex;

View file

@ -318,7 +318,13 @@ const RoomSummaryCard: React.FC<IProps> = ({ room, permalinkCreator, onClose })
/> />
</div> </div>
<RoomName room={room}>{(name) => <h1 title={name}>{name}</h1>}</RoomName> <RoomName room={room}>
{(name) => (
<h1 className="mx_RoomSummaryCard_roomName" title={name}>
{name}
</h1>
)}
</RoomName>
<div className="mx_RoomSummaryCard_alias" title={alias}> <div className="mx_RoomSummaryCard_alias" title={alias}>
{alias} {alias}
</div> </div>

View file

@ -46,6 +46,7 @@ exports[`<RoomSummaryCard /> renders the room summary 1`] = `
/> />
</div> </div>
<h1 <h1
class="mx_RoomSummaryCard_roomName"
title="!room:domain.org" title="!room:domain.org"
> >
!room:domain.org !room:domain.org