Skip to content

Commit 023e7e6

Browse files
authoredMar 1, 2024
fix(core): updates to not show "cannot upload" on hover when using extension based accepts settings (#5881)
1 parent 7ed2b0f commit 023e7e6

File tree

1 file changed

+8
-1
lines changed
  • packages/sanity/src/core/form/studio/uploads

1 file changed

+8
-1
lines changed
 

‎packages/sanity/src/core/form/studio/uploads/accepts.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ export function accepts(file: FileLike, acceptedFiles: string | string[]): boole
2828
const validType = type.trim().toLowerCase()
2929

3030
if (validType.charAt(0) === '.') {
31-
return fileName.toLowerCase().endsWith(validType)
31+
if (fileName) {
32+
return fileName.toLowerCase().endsWith(validType)
33+
}
34+
// If we do not have a valid fileName and validType is an extension, we
35+
// should fail open. This happens because when hovering a file, the browser
36+
// does not pass the name of the file but it will pass the file name when the
37+
// file is dropped on the file upload input
38+
return true
3239
}
3340

3441
if (validType.endsWith('/*')) {

0 commit comments

Comments
 (0)
Please sign in to comment.