-
Notifications
You must be signed in to change notification settings - Fork 12
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
handle cancel on file input #3
Comments
@petha Although there's no specific JS events for recognising this, I think I could find a way. Which would you prefer a promise fail or empty list? |
I'm lending towards empty list since it isn't a failure but either will do. I did some quick experimenting with blur event but couldn't find a way myself. I wonder why the |
We could attach a focus event on the window, so when you cancel, the window comes back into focus, and use boolean variable to check if the focus event that was fired was caused by canceling the file dialog, and not just the user clicking back on the window. |
@alnorris Great idea! Did a quick hack and that would probably work, is it possible rely on the order for change and focus event? |
@petha You have a good point, the only solution I found was you use setTimeOut for a second, and then see if the input field had contents in it, it works, but not very elegant, if you have any ideas let me know. |
Great proposal! I think this is a requirement. I feel like reject makes more sense than resolve though. In my mind, it sound like an attempt to get a file from the user. If the user cancels, the attempt has failed. |
If anyone has a good solution to the problem, rather than the hacky setTimeout please let me know, or better yet make a PR. Thanks |
I think that if no files selected the promise should either fail or resolve with an empty list of files.
The text was updated successfully, but these errors were encountered: