Skip to content

Commit 769c397

Browse files
committed
feat: Set src as key on Thumbnail instances to force the re-render when src change
1 parent 930370a commit 769c397

File tree

1 file changed

+6
-9
lines changed
  • packages/ui/src/elements/Table/DefaultCell/fields/File

1 file changed

+6
-9
lines changed

Diff for: packages/ui/src/elements/Table/DefaultCell/fields/File/index.tsx

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use client'
2-
import type { DefaultCellComponentProps, TextFieldClient, UploadFieldClient } from 'payload'
2+
import type { DefaultCellComponentProps, UploadFieldClient } from 'payload'
33

44
import React from 'react'
55

@@ -8,30 +8,27 @@ import './index.scss'
88

99
const baseClass = 'file'
1010

11-
export interface FileCellProps
12-
extends DefaultCellComponentProps<TextFieldClient | UploadFieldClient> {}
11+
export interface FileCellProps extends DefaultCellComponentProps<any, UploadFieldClient> {}
1312

1413
export const FileCell: React.FC<FileCellProps> = ({
1514
cellData: filename,
16-
collectionConfig,
15+
customCellContext,
1716
rowData,
1817
}) => {
1918
const { collectionSlug, uploadConfig } = customCellContext
20-
const src = rowData?.thumbnailURL || rowData?.url
2119

2220
return (
2321
<div className={baseClass}>
2422
<Thumbnail
2523
className={`${baseClass}__thumbnail`}
26-
collectionSlug={collectionConfig?.slug}
24+
collectionSlug={collectionSlug}
2725
doc={{
2826
...rowData,
2927
filename,
3028
}}
31-
fileSrc={src}
32-
key={src}
29+
fileSrc={rowData?.thumbnailURL || rowData?.url}
3330
size="small"
34-
uploadConfig={collectionConfig?.upload}
31+
uploadConfig={uploadConfig}
3532
/>
3633
<span className={`${baseClass}__filename`}>{String(filename)}</span>
3734
</div>

0 commit comments

Comments
 (0)