Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): keep a row menu on screen in right-to-left pages

Yudhi Armyndharisaa642780c58e
diff --git a/dashboard/src/components/chats/ChatRowMenu.tsx b/dashboard/src/components/chats/ChatRowMenu.tsx
index d8d4f782d..b48023651 100644
--- a/dashboard/src/components/chats/ChatRowMenu.tsx
+++ b/dashboard/src/components/chats/ChatRowMenu.tsx
@@ -93,7 +93,9 @@ function ChatRowMenu({ chat, actions }: { chat: Chat; actions: ChatRowActions })
const top = fitsBelow ? anchor.bottom + gap : Math.max(margin, anchor.top - gap - height);
const start = rtl ? anchor.left : anchor.right - width;
const left = Math.min(Math.max(margin, start), window.innerWidth - width - margin);
- Object.assign(popover.style, { position: 'fixed', top: `${top}px`, left: `${left}px`, insetInlineEnd: 'auto' });
+ // Physical edges: the stylesheet pins the end edge, and releasing it as inset-inline-end would release `left`
+ // in a right-to-left page, throwing the computed position away.
+ Object.assign(popover.style, { position: 'fixed', top: `${top}px`, left: `${left}px`, right: 'auto' });
}, [open]);
// Closes on a press outside and on Escape, which it takes in the capture phase so the page leaves the
diff --git a/dashboard/src/pages/Chats.features.test.ts b/dashboard/src/pages/Chats.features.test.ts
index d2ec96a91..ad365c796 100644
--- a/dashboard/src/pages/Chats.features.test.ts
+++ b/dashboard/src/pages/Chats.features.test.ts
@@ -710,6 +710,19 @@ test("dismissing a dialog the room's menu opened, or the menu itself, returns fo
assert.equal(focusedName(), 'More actions', 'focus fell to the page after Escape');
});
+test("a row's menu is placed by physical edges, so a right-to-left page keeps the position it computed", async () => {
+ const { screen, fireEvent } = rtl;
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ const popover = container.querySelector('.chat-row-menu-popover') as HTMLElement;
+ assert.notEqual(popover.style.left, '', 'no horizontal position was set');
+ // The stylesheet pins the end edge with inset-inline-end. Releasing it with that same logical property would,
+ // right-to-left, release the left edge that was just set; the physical right edge is the one to release.
+ assert.equal(popover.style.right, 'auto', 'the stylesheet still pins the popover by its end edge');
+ assert.ok(!/inset-inline/.test(popover.getAttribute('style') ?? ''), 'a logical edge can undo the physical one');
+});
+
test('archiving a chat moves it into the archive view, and unarchiving brings it back', async () => {
const { screen, fireEvent, waitFor } = rtl;
renderPage();