fix(ui mode): make sure key for attachment view is unique (#32084)

Fixes #32052.
This commit is contained in:
Dmitry Gozman 2024-08-08 10:57:44 -07:00 committed by GitHub
parent 80e014f4b6
commit 44445e30e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,7 +131,7 @@ export const AttachmentsTab: React.FunctionComponent<{
})}
{attachments.size ? <div className='attachments-section'>Attachments</div> : undefined}
{[...attachments.values()].map((a, i) => {
return <div className='attachment-item' key={`attachment-${i}`}>
return <div className='attachment-item' key={attachmentKey(a, i)}>
<ExpandableAttachment attachment={a} />
</div>;
})}
@ -154,3 +154,7 @@ function downloadURL(attachment: Attachment) {
params.dct = attachment.contentType;
return attachmentURL(attachment, params);
}
function attachmentKey(attachment: Attachment, index: number) {
return index + '-' + (attachment.sha1 ? `sha1-` + attachment.sha1 : `path-` + attachment.path);
}