From 1e3320da1ee63308dd10f0c67ce3fea30746ffbb Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Wed, 4 Sep 2024 11:45:18 +0200 Subject: [PATCH] Pinned message list: prevent sender name to overflow pinned event tile (#12947) * Prevent sender name to overflow pinned event tile * Add tooltip to display the sender name --- res/css/views/rooms/_PinnedEventTile.pcss | 3 +++ src/components/views/rooms/PinnedEventTile.tsx | 14 ++++++-------- .../__snapshots__/PinnedMessagesCard-test.tsx.snap | 8 ++++---- .../__snapshots__/PinnedEventTile-test.tsx.snap | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/res/css/views/rooms/_PinnedEventTile.pcss b/res/css/views/rooms/_PinnedEventTile.pcss index b727a5ff5a..c415a4da41 100644 --- a/res/css/views/rooms/_PinnedEventTile.pcss +++ b/res/css/views/rooms/_PinnedEventTile.pcss @@ -26,6 +26,8 @@ limitations under the License. /* Remove avatar width and space between the avatar and the wrapper */ /* We need it to make the location fit */ width: calc(100% - var(--cpd-space-4x) - 32px); + /* Prevent a long sender name to overflow the tile */ + overflow: hidden; .mx_PinnedEventTile_top { display: flex; @@ -37,6 +39,7 @@ limitations under the License. text-overflow: ellipsis; overflow: hidden; white-space: nowrap; + font: var(--cpd-font-body-md-semibold); } } diff --git a/src/components/views/rooms/PinnedEventTile.tsx b/src/components/views/rooms/PinnedEventTile.tsx index 5fb9c07f45..c77cffe776 100644 --- a/src/components/views/rooms/PinnedEventTile.tsx +++ b/src/components/views/rooms/PinnedEventTile.tsx @@ -17,7 +17,7 @@ limitations under the License. import React, { JSX, useCallback, useState } from "react"; import { EventTimeline, EventType, MatrixEvent, Room } from "matrix-js-sdk/src/matrix"; -import { IconButton, Menu, MenuItem, Separator, Text } from "@vector-im/compound-web"; +import { IconButton, Menu, MenuItem, Separator, Tooltip } from "@vector-im/compound-web"; import { Icon as ViewIcon } from "@vector-im/compound-design-tokens/icons/visibility-on.svg"; import { Icon as UnpinIcon } from "@vector-im/compound-design-tokens/icons/unpin.svg"; import { Icon as ForwardIcon } from "@vector-im/compound-design-tokens/icons/forward.svg"; @@ -86,13 +86,11 @@ export function PinnedEventTile({ event, room, permalinkCreator }: PinnedEventTi
- - {event.sender?.name || sender} - + + + {event.sender?.name || sender} + +
should show two pinned messages 1`] = ` class="mx_PinnedEventTile_top" > @alice:example.org @@ -218,7 +218,7 @@ exports[` should show two pinned messages 1`] = ` class="mx_PinnedEventTile_top" > @alice:example.org @@ -347,7 +347,7 @@ exports[` unpin all should not allow to unpinall 1`] = ` class="mx_PinnedEventTile_top" > @alice:example.org @@ -413,7 +413,7 @@ exports[` unpin all should not allow to unpinall 1`] = ` class="mx_PinnedEventTile_top" > @alice:example.org diff --git a/test/components/views/rooms/__snapshots__/PinnedEventTile-test.tsx.snap b/test/components/views/rooms/__snapshots__/PinnedEventTile-test.tsx.snap index bf8cafe2dc..5c44de4c4d 100644 --- a/test/components/views/rooms/__snapshots__/PinnedEventTile-test.tsx.snap +++ b/test/components/views/rooms/__snapshots__/PinnedEventTile-test.tsx.snap @@ -25,7 +25,7 @@ exports[` should render pinned event 1`] = ` class="mx_PinnedEventTile_top" > @alice:server.org @@ -90,7 +90,7 @@ exports[` should render pinned event with thread info 1`] = ` class="mx_PinnedEventTile_top" > @alice:server.org