Skip to content

useFileDialog should also return onCancel handler #4183

@AndreyYolkin

Description

@AndreyYolkin

Clear and concise description of the problem

I want user to pick a file to upload, but i don't know if user still selecting the file or he already closed the picker.

onChange triggers only after files selection/reset, but not after dialog just closed and that's ok, we just need another handle for that

Suggested solution

I propose to extend useFileDialog with additional handler, named onCancel, which will be coupled with native oncancel event and fire a callback when user just closes the picker without picking a file

Alternative

Also I can suggest making open() to return a promise (it's void now), which resolves on file changes and rejects on cancel. It solves our case specifically, but could be a breaking change, especially unhandled rejection

Additional context

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions