fix: say whether a conversation attachment button previews or downloads, next to the file name

This commit is contained in:
Linus Rath
2026-10-29 17:53:59 +01:00
parent da215b8c06
commit 75b4ec37fb
2 changed files with 4 additions and 2 deletions
@@ -67,7 +67,7 @@ describe('conversation controls name their target', () => {
hasAttachment: true,
attachments: [{ partId: '2', blobId: 'blob2', name: 'report.pdf', type: 'application/pdf', size: 2048 }],
})]);
expect(screen.getByRole('button', { name: /^email_viewer\.(download|preview)_named \{"name":"report\.pdf"\}$/ })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /^(email_viewer\.download|files\.preview) report\.pdf/ })).toBeInTheDocument();
});
});
@@ -1013,10 +1013,12 @@ export function ConversationEmailBody({
onDownloadAttachment?.(attachment.blobId, attachment.name || 'attachment', attachment.type, source);
}}
title={opensPreview ? t('files.preview') : t('email_viewer.download')}
aria-label={t(opensPreview ? 'email_viewer.preview_named' : 'email_viewer.download_named', { name: attachment.name ? stripBidiControls(attachment.name) : 'Attachment' })}
className="flex items-center gap-2 px-3 py-2 rounded-lg bg-muted hover:bg-muted/80 transition-colors text-sm"
>
<Icon className="w-4 h-4 text-muted-foreground" />
{/* The action, for screen readers: the visible name alone
doesn't say whether the button previews or downloads. */}
<span className="sr-only">{opensPreview ? t('files.preview') : t('email_viewer.download')}</span>{' '}
<span className="truncate max-w-[150px]">{attachment.name ? stripBidiControls(attachment.name) : 'Attachment'}</span>
<span className="text-muted-foreground text-xs">
{formatFileSize(attachment.size)}