-
Notifications
You must be signed in to change notification settings - Fork 153
fixed 'change' emit, support file extension as mimetype #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
xlvisuals
commented
Jul 18, 2025
- fixed component not emitting 'change' when changing file
- added support for file extension as mime type (as per spec)
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.8 to 7.23.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [browserify-sign](https://github.com/crypto-browserify/browserify-sign) from 4.2.1 to 4.2.2. - [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md) - [Commits](browserify/browserify-sign@v4.2.1...v4.2.2) --- updated-dependencies: - dependency-name: browserify-sign dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.2 to 1.15.4. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](follow-redirects/follow-redirects@v1.15.2...v1.15.4) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]>
…npm_and_yarn/babel/traverse-7.23.2 Bump @babel/traverse from 7.22.8 to 7.23.2
…npm_and_yarn/browserify-sign-4.2.2 Bump browserify-sign from 4.2.1 to 4.2.2
…npm_and_yarn/follow-redirects-1.15.4 Bump follow-redirects from 1.15.2 to 1.15.4
- fixed component not emitting 'change' when changing file - added support for file extension as mime type (as per <input> spec)
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
Improved support for file extensions as accepted file types. Specify any or all file type as extension (e.g. .pdf) instead of their mimetype.
Hi @xlvisuals! First of all, thanks for opening this PR. 🙏
|
Hi! Thanks a lot for looking into this! I briefly tested your new version and found two issues:
I don't understand the logic/benefit of emitting 'change' in onFileChange() and loadImage() and to tie it up with the 'preview' event. I feel like 'change' and 'preview' are unrelated and the else clause is causing issues here.
vue-picture-input, including v4.0.2, only considers mimetypes and not file extensions. That means you can't upload uncommon file types. This can be easily fixed by replacing line 375
with
This allows users to specify extensions (e.g. ".pdf") as well as mimetypes for the accept property. |
I tried with a TIFF image and it worked correctly with preview too. Can you share an image where it doesn't work? (Also, which browser+version?). But yeah, a failure in rendering the preview should not prevent the
Yeah, that logic is really convoluted, I had troubles following too after all this time, and it could definitely benefit from a refactoring. Anyway, it now should behave as intended, from my testing, which means:
I want to also note that prefilling an image is for displaying a placeholder preview only—it doesn't actually change the file of the underlying input, that's never been the case (I will clarify that in the README, as it's been a cause of misunderstanding for other people). Regarding the file type support: got it. Could you open a separate PR just for that, @xlvisuals? I will include it in the next release! |