Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): keep the room header's number on one line

Yudhi Armyndharis5d98abd7ecd3
diff --git a/dashboard/src/bidi.test.ts b/dashboard/src/bidi.test.ts
index 33c25f965..24f49189d 100644
--- a/dashboard/src/bidi.test.ts
+++ b/dashboard/src/bidi.test.ts
@@ -26,7 +26,7 @@ const CHATS_TSX = readFileSync(join(SRC, 'pages/Chats.tsx'), 'utf8');
test('the open chat header isolates the phone number, and the contact panel the raw id', () => {
assert.match(
CHATS_TSX,
- /<span className="room-contact-phone">\s*<bdi dir="ltr">\{activePhoneText\}<\/bdi>/,
+ /<span className="room-contact-phone"[^>]*>\s*<bdi dir="ltr">\{activePhoneText\}<\/bdi>/,
'the header number is not isolated',
);
assert.match(
@@ -43,6 +43,28 @@ test('the header number keeps the page direction, so it sits at the start edge w
assert.doesNotMatch(body('pages/Chats.css', '.chats-page .room-contact-phone'), /unicode-bidi/);
});
+test('the header number stays on one line in a narrow room, cut by its own isolate, with the whole number in its title', () => {
+ // At the room's 262px minimum the number wrapped onto a second line under the name. Cut by the isolate, written left
+ // to right, it loses its last digits in either page direction, as the session number does.
+ assert.match(
+ CHATS_TSX,
+ /<span className="room-contact-phone" title=\{activePhoneText\}>/,
+ 'the header number has no title',
+ );
+ const line = body('pages/Chats.css', '.chats-page .room-contact-phone');
+ assert.match(line, /display:\s*flex/);
+ assert.match(line, /min-width:\s*0/);
+ const cut = body('pages/Chats.css', '.chats-page .room-contact-phone > bdi');
+ for (const declaration of [
+ /white-space:\s*nowrap/,
+ /overflow:\s*hidden/,
+ /text-overflow:\s*ellipsis/,
+ /min-width:\s*0/,
+ ]) {
+ assert.match(cut, declaration);
+ }
+});
+
test('text cut with an ellipsis takes its direction from its own characters', () => {
// The ellipsis removes the end of the line in the direction of the box. Under the page direction a Latin name in
// an Arabic page (or an Arabic one in an English page) lost its first letters and kept its last.
diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.css
index d1a4c2ae2..f517c18eb 100644
--- a/dashboard/src/pages/Chats.css
+++ b/dashboard/src/pages/Chats.css
@@ -1811,13 +1811,23 @@
}
/* The number under the name is isolated left to right in the markup (<bdi dir="ltr">), so the line keeps the page
- direction and sits at the start edge with the name. */
-
+ direction and sits at the start edge with the name. It stays on one line in a narrow room, cut by its own isolate
+ as the session number is (see .session-phone-line): its last digits give way, in either page direction, and the
+ whole number is in its title. */
.chats-page .room-contact-phone {
+ display: flex;
+ min-width: 0;
font-size: 0.8125rem;
color: var(--chat-meta);
}
+.chats-page .room-contact-phone > bdi {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
.chats-page .room-header-actions {
display: flex;
align-items: center;
diff --git a/dashboard/src/pages/Chats.tsx b/dashboard/src/pages/Chats.tsx
index e6a812e4f..6b88109b8 100644
--- a/dashboard/src/pages/Chats.tsx
+++ b/dashboard/src/pages/Chats.tsx
@@ -1986,7 +1986,7 @@ export function Chats() {
must never be formatted as one). Only under a saved name: an unnamed chat's
title already is the number. The raw JID is in the contact panel. */}
{activePhoneText && activeChat.name && (
- <span className="room-contact-phone">
+ <span className="room-contact-phone" title={activePhoneText}>
<bdi dir="ltr">{activePhoneText}</bdi>
</span>
)}