Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): name the archived media placeholder for screen readers
Yudhi Armyndharisa07e04b478dd
diff --git a/dashboard/src/components/chats/ArchivedMediaPreview.test.ts b/dashboard/src/components/chats/ArchivedMediaPreview.test.tsindex ff543f47a..99bd0f12c 100644--- a/dashboard/src/components/chats/ArchivedMediaPreview.test.ts+++ b/dashboard/src/components/chats/ArchivedMediaPreview.test.ts@@ -18,6 +18,8 @@ const revoked: string[] = [];before(async () => {const { installJsdomGlobals } = await import('../../test-helpers/jsdom.ts');await installJsdomGlobals();+ const { i18nReady } = await import('../../i18n/index.ts');+ await i18nReady;rtl = await import('@testing-library/react');({ default: ArchivedMediaPreview } = await import('./ArchivedMediaPreview.tsx'));// jsdom implements neither.@@ -262,3 +264,10 @@ test('previews mounted together start their fetches apart, so a burst stays unde);}});++test('an archived placeholder is announced as loading, not left as an unnamed element', () => {+ rtl.render(+ createElement(ArchivedMediaPreview, { kind: 'image', fallback, load: () => new Promise<Blob>(() => undefined) }),+ );+ assert.ok(rtl.screen.getByRole('status', { name: 'Loading...' }));+});diff --git a/dashboard/src/components/chats/ArchivedMediaPreview.tsx b/dashboard/src/components/chats/ArchivedMediaPreview.tsxindex c5b5c3880..8322fc885 100644--- a/dashboard/src/components/chats/ArchivedMediaPreview.tsx+++ b/dashboard/src/components/chats/ArchivedMediaPreview.tsx@@ -1,5 +1,6 @@import { useEffect, useRef, useState, type ReactNode, type RefObject } from 'react';import { Loader2 } from 'lucide-react';+import { useTranslation } from 'react-i18next';import MediaLightbox from './MediaLightbox';import { loadArchivedMedia } from '../../utils/archivedMediaLoad';@@ -49,6 +50,7 @@ function ArchivedMediaPreview({measureMedia,onMediaLoad,}: ArchivedMediaPreviewProps) {+ const { t } = useTranslation();const [state, setState] = useState<PreviewState>({ phase: 'waiting' });const [imageOpen, setImageOpen] = useState(false);const anchorRef = useRef<HTMLDivElement | null>(null);@@ -131,7 +133,9 @@ function ArchivedMediaPreview({<divref={anchorRef}className={`message-media-omitted message-media-archived-loading${kind === 'audio' ? ' message-media-archived-loading-audio' : ''}`}+ role="status"aria-busy="true"+ aria-label={t('common.loading')}><Loader2 size={14} className="animate-spin" /></div>