Skip to content

Commit 62fcf18

Browse files
authored
fix(ui): upload dropzone error when collectionConfig is undefined (#14043)
### What? Fixes a bug where dragging a file into an upload dropzone when the drawer is closed throws an error: "Cannot read properties of undefined". ### Why? The `collectionConfig` variable can be undefined when the drawer is not opened, causing the code to fail when trying to access `collectionConfig.upload?.displayPreview`. ### How? Added optional chaining (`?.`) to safely access `collectionConfig`, changing `collectionConfig.upload?.displayPreview` to `collectionConfig?.upload?.displayPreview`. Fixes #13999
1 parent bbff65c commit 62fcf18

File tree

1 file changed

+1
-1
lines changed
  • packages/ui/src/fields/Upload/RelationshipContent

1 file changed

+1
-1
lines changed

packages/ui/src/fields/Upload/RelationshipContent/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function RelationshipContent(props: Props) {
8989
}
9090

9191
const metaText = withMeta ? generateMetaText(mimeType, byteSize) : ''
92-
const previewAllowed = displayPreview ?? collectionConfig.upload?.displayPreview ?? true
92+
const previewAllowed = displayPreview ?? collectionConfig?.upload?.displayPreview ?? true
9393

9494
return (
9595
<div className={[baseClass, className].filter(Boolean).join(' ')}>

0 commit comments

Comments
 (0)