Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): say an archived image opens a dialog

Yudhi Armyndharisb530799710e5
diff --git a/dashboard/src/components/chats/ArchivedMediaPreview.test.ts b/dashboard/src/components/chats/ArchivedMediaPreview.test.ts
index 99bd0f12c..355d4a09e 100644
--- a/dashboard/src/components/chats/ArchivedMediaPreview.test.ts
+++ b/dashboard/src/components/chats/ArchivedMediaPreview.test.ts
@@ -271,3 +271,17 @@ test('an archived placeholder is announced as loading, not left as an unnamed el
);
assert.ok(rtl.screen.getByRole('status', { name: 'Loading...' }));
});
+
+test('an archived image is a named button that says it opens a dialog', async () => {
+ rtl.render(
+ createElement(ArchivedMediaPreview, {
+ kind: 'image',
+ alt: 'photo.jpg',
+ fallback,
+ load: async () => new Blob(['x'], { type: 'image/jpeg' }),
+ }),
+ );
+ const button = await rtl.screen.findByRole('button', { name: 'photo.jpg' });
+ // The viewer is a dialog; without this a screen reader announces a bare "photo.jpg, button".
+ assert.equal(button.getAttribute('aria-haspopup'), 'dialog');
+});
diff --git a/dashboard/src/components/chats/ArchivedMediaPreview.tsx b/dashboard/src/components/chats/ArchivedMediaPreview.tsx
index 8322fc885..fc1a451c1 100644
--- a/dashboard/src/components/chats/ArchivedMediaPreview.tsx
+++ b/dashboard/src/components/chats/ArchivedMediaPreview.tsx
@@ -154,6 +154,7 @@ function ArchivedMediaPreview({
ref={measureMedia}
onLoad={onMediaLoad}
role="button"
+ aria-haspopup="dialog"
tabIndex={0}
onClick={() => setImageOpen(true)}
onKeyDown={event => {