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

Error when user tries to drop text #68

Closed
crizant-mpower opened this issue Aug 3, 2023 · 9 comments
Closed

Error when user tries to drop text #68

crizant-mpower opened this issue Aug 3, 2023 · 9 comments

Comments

@crizant-mpower
Copy link

Select some text on the address bar, then drag it over the dropzone,
the following error is thrown:

Error: Expected a value of type
'File$', but got one of type 'String'
../dart-sdk/lib/_internal/js_dev_runtim
e/private/ddc_runtime/errors.dart
288:49      throw_
../dart-sdk/lib/_internal/js_dev_runtim
e/private/ddc_runtime/errors.dart 121:3
castError
@deakjahn
Copy link
Owner

deakjahn commented Aug 3, 2023

@crizant-mpower Yep but I'm not yet sure what the best solution would be. onDrop() has a File as second argument. We could change it to dynamic (just like onDropMultiple()) but that would be a breaking change of the interface. We could also add a different onDrop() variant but I can't really see why.

@deakjahn
Copy link
Owner

deakjahn commented Aug 3, 2023

Wait a minute... The handler itself is OK, it was an intermediate function somewhere with the File argument...

Check out the changes, please.

@deakjahn deakjahn reopened this Aug 3, 2023
@crizant-mpower
Copy link
Author

crizant-mpower commented Aug 12, 2023

Thanks. I'm fine with the changes. Looking forward to the next release.

@deakjahn
Copy link
Owner

Published now.

@crizant-mpower
Copy link
Author

crizant-mpower commented Aug 14, 2023

Sorry, it seems you forgot to update the onDropMultiple method.
When I drop text, the onDropMultiple method is not invoked.

@deakjahn
Copy link
Owner

deakjahn commented Aug 14, 2023

Oh, dear me, that'll be an async problem with JavaScript...

@deakjahn deakjahn reopened this Aug 14, 2023
@deakjahn
Copy link
Owner

@crizant-mpower OK, this is definitively something I don't want to publish before you test it. :-) See 7230085

Basically, getting the string is async so we actually went on to fire (or not fire) onDropMultiple before the string got a chance to be set (files are not problematic because, for some obscure reason, getting them is sync). I added a private helper function to make getting the string synchronous. The change is straightforward and seems to work for my simple tests but let's be sure first...

@crizant-mpower
Copy link
Author

@crizant-mpower OK, this is definitively something I don't want to publish before you test it. :-) See 7230085

Basically, getting the string is async so we actually went on to fire (or not fire) onDropMultiple before the string got a chance to be set (files are not problematic because, for some obscure reason, getting them is sync). I added a private helper function to make getting the string synchronous. The change is straightforward and seems to work for my simple tests but let's be sure first...

I tested and it works like a charm. 🎉

@deakjahn
Copy link
Owner

Then it's released again, thanks.

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