Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): keep a search hit's id and time in order in RTL

Yudhi Armyndharise0a4b02f5621
diff --git a/dashboard/src/components/GlobalSearch.test.ts b/dashboard/src/components/GlobalSearch.test.ts
index 89fb089a2..224f8d313 100644
--- a/dashboard/src/components/GlobalSearch.test.ts
+++ b/dashboard/src/components/GlobalSearch.test.ts
@@ -379,3 +379,18 @@ test('Escape with focus on "more" closes the results and is consumed', async ()
assert.equal(fireEvent.keyDown(more, { key: 'Escape' }), false, 'Escape on "more" was not consumed');
assert.ok(!screen.queryByRole('listbox'), 'Escape on "more" left the results open');
});
+
+test('a hit shows its chat id and time as isolated runs, so a right-to-left page keeps them readable', async () => {
+ const { screen, act } = rtl;
+ rtl.render(createElement(GlobalSearch, { onHit: () => undefined }));
+ const input = screen.getByRole('textbox');
+ await typeAndWaitForRequest(input, 'alice');
+ await act(async () => pending.get('alice')!(['alice replied']));
+ const meta = (await screen.findByRole('listbox')).querySelector('.global-search-hit-meta');
+ assert.ok(meta, 'the hit has no meta line');
+ // A <bdi> takes its direction from its own text, so the Latin id and the digits stay in order inside Arabic or Hebrew text.
+ assert.deepEqual(
+ [...meta.querySelectorAll('bdi')].map(run => run.textContent),
+ ['[email protected]', new Date(1_767_225_600 * 1000).toLocaleString()],
+ );
+});
diff --git a/dashboard/src/components/GlobalSearch.tsx b/dashboard/src/components/GlobalSearch.tsx
index 08ffde767..c6faebe7b 100644
--- a/dashboard/src/components/GlobalSearch.tsx
+++ b/dashboard/src/components/GlobalSearch.tsx
@@ -196,7 +196,8 @@ export function GlobalSearch({ onHit, currentSessionId }: GlobalSearchProps) {
}}
>
<div className="global-search-hit-meta">
- {h.chatId} · {new Date(h.timestamp * 1000).toLocaleString()}
+ {/* bdi: the id and the time read left to right even inside right-to-left text. */}
+ <bdi>{h.chatId}</bdi> · <bdi>{new Date(h.timestamp * 1000).toLocaleString()}</bdi>
</div>
<div className="global-search-hit-snippet">
{renderHighlightedSnippet(h.snippet).map((seg, i) =>