Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): keep the chat header number and id readable in RTL
Yudhi Armyndharisea3e0c0f4339
diff --git a/dashboard/src/bidi.test.ts b/dashboard/src/bidi.test.tsnew file mode 100644index 000000000..a5fb3f87e--- /dev/null+++ b/dashboard/src/bidi.test.ts@@ -0,0 +1,33 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { readFileSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { dirname, join } from 'node:path';++// Under <html dir="rtl"> a phone number or an id shown as plain text is laid out right to left: "+1 555 000 1111"+// reads "1111 000 555 1+" and "[email protected]" splits around the at sign. Each such value has to be+// isolated so it keeps its own left to right order.++const SRC = dirname(fileURLToPath(import.meta.url));++function body(file: string, selector: string): string {+ const css = readFileSync(join(SRC, file), 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');+ for (const m of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {+ if (m[1].split(',').some(s => s.trim() === selector)) return m[2];+ }+ assert.fail(`${file} has no ${selector} rule`);+}++test('the open chat header isolates the phone number and the raw id', () => {+ for (const selector of ['.chats-page .room-contact-phone', '.chats-page .room-contact-jid']) {+ assert.match(body('pages/Chats.css', selector), /unicode-bidi:\s*plaintext/, selector);+ }+});++test('the header lines hug the start edge with the name instead of stretching across it', () => {+ // A paragraph of digits or Latin letters resolves to left to right under plaintext, so inside a stretched box+ // its text would sit on the left of an Arabic header while the name sits on the right.+ for (const selector of ['.chats-page .room-contact-phone', '.chats-page .room-contact-jid']) {+ assert.match(body('pages/Chats.css', selector), /align-self:\s*flex-start/, selector);+ }+});diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex 9651aa783..173ac10e3 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -426,6 +426,11 @@font-size: 0.8125rem;color: var(--text-muted);line-height: 1.2;+ /* A number or the Group label: each takes its direction from its own text, so a phone keeps its digit+ order inside Arabic and Hebrew pages. A line of digits resolves to left to right, so the box hugs the+ start edge of the header (the right one in RTL, where the name is) instead of stretching across it. */+ unicode-bidi: plaintext;+ align-self: flex-start;}/* Raw JID preserved for technical use (lid resolution, webhook payloads, group ids). Muted mono,@@ -438,6 +443,9 @@white-space: nowrap;overflow: hidden;text-overflow: ellipsis;+ unicode-bidi: plaintext;+ max-width: 100%;+ align-self: flex-start;}.chats-page .room-messages {