Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): keep message text and the session number in their own direction
Rezk Jörg Sebening4f0a3aae6257
diff --git a/dashboard/src/bidi.test.ts b/dashboard/src/bidi.test.tsindex 0b7e293fb..29bf9a8c6 100644--- a/dashboard/src/bidi.test.ts+++ b/dashboard/src/bidi.test.ts@@ -91,6 +91,21 @@ test('cut text that a flex column stretches hugs the start edge, where its sibliassert.match(quote, /max-width:\s*min\(\d+px,\s*100%\)/);});+test('a message body takes its direction from its own characters', () => {+ // Under the page direction an English question in an Arabic page drew its question mark at the left.+ assert.match(body('pages/Chats.css', '.chats-page .message-content > .message-text'), /unicode-bidi:\s*plaintext/);+});++test('the session number is cut by its own isolate, so an RTL page keeps its first digits', () => {+ // The line around it keeps the page direction; cut there, an Arabic page lost "+4" and kept the last digits.+ const picker = readFileSync(join(SRC, 'components/chats/SessionPicker.tsx'), 'utf8');+ assert.match(picker, /<span className="session-phone-line">[\s\S]*?<bdi dir="ltr">/);+ const cut = body('pages/Chats.css', '.chats-page .session-phone-line > bdi');+ assert.match(cut, /text-overflow:\s*ellipsis/);+ assert.match(cut, /min-width:\s*0/);+ assert.match(body('pages/Chats.css', '.chats-page .session-phone-line'), /max-width:\s*100%/);+});+test('chart plots stay left to right on a right to left page', () => {assert.match(body('components/DashboardCharts.css', '.dashboard-charts .recharts-surface'), /direction:\s*ltr/);});diff --git a/dashboard/src/components/chats/SessionPicker.tsx b/dashboard/src/components/chats/SessionPicker.tsxindex f1f513652..db63b5458 100644--- a/dashboard/src/components/chats/SessionPicker.tsx+++ b/dashboard/src/components/chats/SessionPicker.tsx@@ -40,7 +40,7 @@ function PhoneLine({ phone }: { phone?: string | null }) {if (!phone) return <>{t('chats.noPhone')}</>;const region = regionOfPhone(phone);return (- <>+ <span className="session-phone-line">{region && (<span className="session-flag" aria-hidden="true">{flagOfRegion(region)}@@ -48,7 +48,7 @@ function PhoneLine({ phone }: { phone?: string | null }) {)}{/* Digits and + carry no direction of their own: without ltr a right-to-left page reverses them. */}<bdi dir="ltr">{formatPhoneForDisplay(phone) ?? phone}</bdi>- </>+ </span>);}@@ -231,11 +231,13 @@ function SessionPicker({ sessions, selectedSessionId, onSelectSession, canAddSes<SessionAvatar session={session} size="sm" /><span className="session-text"><span className="session-name">{session.name}</span>- <span className="session-phone">+ <span className={`session-phone${session.pushName ? ' with-push-name' : ''}`}>{session.pushName && (<><bdi>{session.pushName}</bdi>- <span aria-hidden="true"> · </span>+ <span className="session-push-name-sep" aria-hidden="true">+ {' · '}+ </span></>)}<PhoneLine phone={session.phone} />diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex dc777e1c0..730694268 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -264,6 +264,43 @@.chats-page .session-flag {margin-inline-end: 0.3em;+ flex-shrink: 0;+}++/* The number is cut by its own box. The line around it keeps the page direction, so in an Arabic page its+ ellipsis took the number's first digits ("...9 151 123 4 5678"); the isolate, written left to right, cuts its+ last ones instead, and the flag stays whole beside it. */+.chats-page .session-phone-line {+ display: inline-flex;+ max-width: 100%;+ vertical-align: bottom;+}++.chats-page .session-phone-line > bdi {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+}++/* In the picker the account's name comes first; it is the part that gives way, so the number stays whole. */+.chats-page .session-phone.with-push-name {+ display: flex;+ min-width: 0;+}++.chats-page .session-phone.with-push-name > bdi {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+}++.chats-page .session-phone.with-push-name > .session-push-name-sep {+ flex-shrink: 0;+ white-space: pre;+}++.chats-page .session-phone.with-push-name > .session-phone-line {+ flex-shrink: 0;}.chats-page .session-chevron {@@ -2112,9 +2149,14 @@word-break: break-word;}+/* A message is written in its own direction, not the page's: under an inherited right to left an English+ question in an Arabic page drew its question mark at the left ("?quote for the kitchen project"). On an inline+ box plaintext isolates the text and reads its direction from the first strong letter, while the bubble keeps+ aligning it by the page direction. */.chats-page .message-content > .message-text {display: inline;white-space: pre-wrap;+ unicode-bidi: plaintext;}.chats-page .message-content > .message-poll-options {