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

handle cancel on file input #3

Open
petha opened this issue Mar 17, 2017 · 7 comments
Open

handle cancel on file input #3

petha opened this issue Mar 17, 2017 · 7 comments

Comments

@petha
Copy link

petha commented Mar 17, 2017

I think that if no files selected the promise should either fail or resolve with an empty list of files.

@alnorris
Copy link
Owner

@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?

@petha
Copy link
Author

petha commented Mar 22, 2017

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
spec does not include a cancel event..

@alnorris
Copy link
Owner

alnorris commented Mar 22, 2017

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.

@petha
Copy link
Author

petha commented Mar 22, 2017

@alnorris Great idea! Did a quick hack and that would probably work, is it possible rely on the order for change and focus event?

@alnorris
Copy link
Owner

@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.

@QuentinRoy
Copy link

QuentinRoy commented Aug 12, 2017

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.

@alnorris
Copy link
Owner

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

Repository owner locked as resolved and limited conversation to collaborators Oct 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants