Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): title the session switcher's number where it is cut
Yudhi Armyndharis27f302ebd8e7
diff --git a/dashboard/src/bidi.test.ts b/dashboard/src/bidi.test.tsindex 24f49189d..dba66ba0a 100644--- a/dashboard/src/bidi.test.ts+++ b/dashboard/src/bidi.test.ts@@ -133,7 +133,7 @@ test('a message body takes its direction from its own characters', () => {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">/);+ 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/);diff --git a/dashboard/src/components/chats/SessionPicker.tsx b/dashboard/src/components/chats/SessionPicker.tsxindex dfac2142f..e9030e412 100644--- a/dashboard/src/components/chats/SessionPicker.tsx+++ b/dashboard/src/components/chats/SessionPicker.tsx@@ -40,6 +40,7 @@ function PhoneLine({ phone }: { phone?: string | null }) {const { t } = useTranslation();if (!phone) return <>{t('chats.noPhone')}</>;const region = regionOfPhone(phone);+ const number = formatPhoneForDisplay(phone) ?? phone;return (<span className="session-phone-line">{region && (@@ -47,8 +48,11 @@ function PhoneLine({ phone }: { phone?: string | null }) {{flagOfRegion(region)}</span>)}- {/* Digits and + carry no direction of their own: without ltr a right-to-left page reverses them. */}- <bdi dir="ltr">{formatPhoneForDisplay(phone) ?? phone}</bdi>+ {/* Digits and + carry no direction of their own: without ltr a right-to-left page reverses them. A narrow list+ column cuts the number, so the whole of it is in its title. */}+ <bdi dir="ltr" title={number}>+ {number}+ </bdi></span>);}diff --git a/dashboard/src/pages/Chats.features.test.ts b/dashboard/src/pages/Chats.features.test.tsindex e2ab99d2b..838024aa6 100644--- a/dashboard/src/pages/Chats.features.test.ts+++ b/dashboard/src/pages/Chats.features.test.ts@@ -1035,6 +1035,20 @@ test('the session switcher lists every session with its state, and only a connecassert.equal(screen.getAllByRole('option').length, 1, 'the search did not narrow the list');});+test('the session switcher gives the whole number of each session in its title, for a list column that cuts it', async () => {+ const { screen, fireEvent } = rtl;+ listOffline = true;+ const { container } = renderPage();+ await screen.findByText('Alice');+ const titleIn = (scope: Element | null) => scope?.querySelector('.session-phone-line bdi')?.getAttribute('title');+ assert.equal(titleIn(container.querySelector('.session-switcher-btn')), '+1 555 123 4567');+ fireEvent.click(container.querySelector('.session-switcher-btn') as HTMLElement);+ assert.deepEqual(+ screen.getAllByRole('option').map(option => titleIn(option)),+ ['+1 555 123 4567', '+49 174 156 5212'],+ );+});+test('the session switcher matches a number only for a query that reads as one, and a name with a digit by name', async () => {const { screen, fireEvent, waitFor } = rtl;listSecond = true;