diff --git a/packages/components/file/src/js/file.controller.js b/packages/components/file/src/js/file.controller.js index 2d5a4403..e92d84b7 100644 --- a/packages/components/file/src/js/file.controller.js +++ b/packages/components/file/src/js/file.controller.js @@ -39,11 +39,11 @@ export default class { const hasTypeError = !acceptedTypes.some((acceptedType) => { const [type, extension] = acceptedType.split('/'); if (extension) { - const isTypeValid = type === '*' || type.toLowerCase() === fileType.toLowerCase(); - const isExtensionValid = extension === '*' || extension.toLowerCase() === fileExtension.toLowerCase(); + const isTypeValid = type === '*' || type.toLowerCase() === fileType?.toLowerCase(); + const isExtensionValid = extension === '*' || extension.toLowerCase() === fileExtension?.toLowerCase(); return isTypeValid && isExtensionValid; } - return type === '*' || type.replace('.', '').toLowerCase() === fileExtension.toLowerCase(); + return type === '*' || type.replace('.', '').toLowerCase() === fileExtension?.toLowerCase(); }); if (hasTypeError) { file.errors.type = true; diff --git a/packages/components/file/src/js/file.html b/packages/components/file/src/js/file.html index 8a1d727a..5c5263dd 100644 --- a/packages/components/file/src/js/file.html +++ b/packages/components/file/src/js/file.html @@ -142,11 +142,15 @@ + + diff --git a/packages/components/file/src/js/file.provider.js b/packages/components/file/src/js/file.provider.js index 5a332534..ce943705 100644 --- a/packages/components/file/src/js/file.provider.js +++ b/packages/components/file/src/js/file.provider.js @@ -14,6 +14,7 @@ export default class { maxsizeError: 'This file exceeds the size limit', notSingleError: 'You can only add one file', removeFile: 'Remove file from selector', + typeError: 'This file extension is not supported', }; this.units = [