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

How to detect when the file picker is canceled? #88

Closed
f957-cua opened this issue Feb 13, 2024 · 5 comments
Closed

How to detect when the file picker is canceled? #88

f957-cua opened this issue Feb 13, 2024 · 5 comments
Labels
wontfix This will not be worked on

Comments

@f957-cua
Copy link

Hi there!
Brilliant package with many options.

It would be nice to have an onCancel callback to control this stage properly.

I mean to control the cancel button and the picker window close button.

Approach to openning filePicker simultaneously with backdrop behind is very popular nowadays.
And how to cover the case closing backdrop if user close filePicker with any selected files.

I have found the same needs with another library:
pnp/sp-dev-fx-controls-react#665

@MrKampla
Copy link
Collaborator

Hi @f957-cua,
I'm afraid I don't have a good answer to your question. Some time ago we wanted to change the open file picker function to return a promise, but it turned out there's no way of implementing rejection reliably across different browsers when user cancels the file selection. Blur and focus events are not fired correctly in browsers, so a user has to make some sort of an action like a click, to focus back the window.
You can find more details here:
#58 (comment)

If you want to add a backdrop, I'd probably try to make a workaround by adding a visual element that clearly indicates user has to click on it in order to dismiss. For example a button with an unambiguous icon in the middle of the screen.

@f957-cua
Copy link
Author

Hi @MrKampla,
Thanks for your quick answer.
Close backdrop is not a bid deal, you can just click on it.
But I want to avoid this click and receive info from package, what file picker window was closed.

Is it possible?

@MrKampla
Copy link
Collaborator

I understand, but as I said, there's no reliable way of doing that, so use-file-picker package is also not offering such functionality.

@f957-cua
Copy link
Author

I know.
You're maintaining a nice product, from my POV.
It's only wish for the future.)
Don't give up on this idea, maybe in the future something will have been changed in browsers with event handling.

@Jaaneek Jaaneek added the wontfix This will not be worked on label Feb 15, 2024
@Jaaneek
Copy link
Owner

Jaaneek commented Feb 15, 2024

As @MrKampla said:

I understand, but as I said, there's no reliable way of doing that, so use-file-picker package is also not offering such functionality.

I'm closing it, feel free to open another issue if you have any questions

@Jaaneek Jaaneek closed this as completed Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants