diff --git a/packages/flow-core/CHANGELOG.md b/packages/flow-core/CHANGELOG.md index 946ea6ca7..8faf64a14 100644 --- a/packages/flow-core/CHANGELOG.md +++ b/packages/flow-core/CHANGELOG.md @@ -2,6 +2,12 @@ # Change Log +## [2.9.9] - 2024-04-04 + +### Bug Fixes + +- File extension validation logic added when the user drops files + ## [2.9.8] - 2024-04-01 ### Bug Fixes diff --git a/packages/flow-core/package.json b/packages/flow-core/package.json index 089203c25..7fdd850a7 100644 --- a/packages/flow-core/package.json +++ b/packages/flow-core/package.json @@ -1,6 +1,6 @@ { "name": "@ollion/flow-core", - "version": "2.9.8", + "version": "2.9.9", "description": "Core package of flow design system", "module": "dist/flow-core.es.js", "main": "dist/flow-core.cjs.js", diff --git a/packages/flow-core/src/components/f-file-upload/f-file-upload.ts b/packages/flow-core/src/components/f-file-upload/f-file-upload.ts index afd830acf..ab25424ac 100644 --- a/packages/flow-core/src/components/f-file-upload/f-file-upload.ts +++ b/packages/flow-core/src/components/f-file-upload/f-file-upload.ts @@ -12,6 +12,7 @@ import { unsafeSVG } from "lit-html/directives/unsafe-svg.js"; import loader from "../../mixins/svg/loader"; import { flowElement } from "./../../utils"; import { injectCss } from "@ollion/flow-core-config"; +import { ifDefined } from "lit/directives/if-defined.js"; injectCss("f-file-upload", globalStyle); export type FFileUploadState = "primary" | "default" | "success" | "warning" | "danger"; @@ -219,10 +220,17 @@ export class FFileUpload extends FRoot { e.preventDefault(); const files = e.dataTransfer?.files; const filesArr = files ? Array.from(files) : []; + if (this.fileType !== "all") { - this.acceptedFilesFlag = filesArr.every( - item => item.type && this.fileType?.includes(item.type.split("/")[1]) - ); + this.acceptedFilesFlag = filesArr.every(item => { + // check extention as well + const fileExtention = item.name.substring(item.name.lastIndexOf(".")); + return ( + item.type && + (this.fileType?.includes(item.type.split("/")[1]) || + this.fileType?.includes(fileExtention)) + ); + }); } this.sizeLimitFlag = this.maxSize && this.bytes ? filesArr.every(item => item.size < this.bytes) : true; @@ -471,8 +479,8 @@ export class FFileUpload extends FRoot {