Skip to content
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

onError or onLeave not called when incorrect mime type dropped #66

Closed
gbmiranda opened this issue Jul 26, 2023 · 18 comments
Closed

onError or onLeave not called when incorrect mime type dropped #66

gbmiranda opened this issue Jul 26, 2023 · 18 comments

Comments

@gbmiranda
Copy link

Hi,

onLeave or onError is not being called after dropping a file not allowed by the mime type.

Any chance of correction?

@gbmiranda gbmiranda changed the title onError or onLeave not called when incorrect mime tyoe onError or onLeave not called when incorrect mime type dropped Jul 26, 2023
@deakjahn
Copy link
Owner

I'm not really sure this would be a good idea, it was never intended that way. MIME types simply restrict the droppable files but don't necessarily mean a hard error. It would certainly be a breaking change if we modified that behavior now...

@gbmiranda
Copy link
Author

Hi, thanks for the quick response! Your arguments are valid, but we have some situations:

1- the onHover is called for files not accepted and I highlight the zone, if the user tries to add I have no event afterwards to remove the highlight and give a feedback warning that files are not accepted, maybe create a new event called onDropInvalid ?
2- another UX suggestion, when I place the file above the zone, the cursor shows a green icon, when for an invalid file, it displays a red icon.

I even managed to solve the hover issue by adding a MouseRegion over the zone and controlling it by onEnter / onExite, but I still haven't seen a way to display feedback to the user warning that the file is not accepted.

@deakjahn
Copy link
Owner

@gbmiranda Adding a new callback wasn't that complicated. Please, check it out.

@deakjahn deakjahn reopened this Jul 27, 2023
@gbmiranda
Copy link
Author

Perfect thank you! Will you publish to pub.dev?

@deakjahn
Copy link
Owner

If you say it's safe to do so...

@gbmiranda
Copy link
Author

onDropInvalid event was not called :(

@deakjahn
Copy link
Owner

I tried the example, even left the MIME there for now and it works for me. Did you try that directly?

@gbmiranda
Copy link
Author

I tried it on my own project, here's a print of the code.

mime: ['image/jpeg', 'image/jpg', 'image/png'];

Captura de Tela 2023-07-28 às 08 24 30

When I drop a CSV or ZIP file, the onDropInvalid event does not fire

@deakjahn
Copy link
Owner

Then first, please, try the example, that's the one we have in common...

@gbmiranda
Copy link
Author

if I download the example and run it, it works, but when I put it in my project with version 3.0.6 it doesn't. Even if I exactly copy your DropZone implementation the onDropInvalid event is not called.

Could it be that something was missing from the uploaded version?

@deakjahn
Copy link
Owner

deakjahn commented Jul 29, 2023

Strange. All three seem to be upgraded:

Do check in your Pub\Cache\hosted\pub.dev that you have these versions of all three.

I'll try to reproduce it in a standalone test in the meantime.

@deakjahn
Copy link
Owner

deakjahn commented Jul 29, 2023

@gbmiranda I really can't get a handle on this yet. I started a new project, web only. I copied main.dart from the plugin example. Here it is packed, I modified nothing else from the standard Flutter project template:
untitled.zip but it references the current version from Pub.dev.

And it runs just fine:

Untitled-1

@deakjahn
Copy link
Owner

What you could do is to put a breakpoint here in your browser Dev Tools and see what really happens, step by step:

if (this.dropMIME == null || this.dropMIME.includes(item.type)) {
var file = item.getAsFile();
if (this.onDrop != null) this.onDrop(event, file);
files.push(file);
}
else {
if (this.onDropInvalid != null) this.onDropInvalid(event, item.type);
}

@gbmiranda
Copy link
Author

I'm thinking it's a flutter package caching problem... the file you sent me doesn't have the onDropInvalid handlers

Captura de Tela 2023-07-31 às 10 06 27

@gbmiranda
Copy link
Author

For some reason I need to override flutter_dropzone_web to get the right version.

Working now!

Captura de Tela 2023-07-31 às 10 35 10

@deakjahn
Copy link
Owner

I didn't yet change it to .10 in the .yaml, that's true, but it should work, anyway, this is rather strange. What if you delete all the version folders in the pub cache and run pub get again? Do you get version .10 then?

@gbmiranda
Copy link
Author

takes 3.0.9 and 3.0.10, but for some reason when I build it uses 3.0.9... it only works if I override it.

@deakjahn
Copy link
Owner

deakjahn commented Aug 1, 2023

Who knows. I advanced the version now here and it will appear in the next published one.

@deakjahn deakjahn closed this as completed Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants