Skip to content

Commit

Permalink
fix(filechooser): cancel is sync (#6937)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: FileChooser.cancel() is now synchronous.
  • Loading branch information
kblok committed Mar 2, 2021
1 parent 0c26301 commit 2ba61e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,6 @@ await fileChooser.accept(['/tmp/myfile.pdf']);
- returns: <[Promise]>

#### fileChooser.cancel()
- returns: <[Promise]>

Closes the file chooser without selecting any files.

Expand Down
2 changes: 1 addition & 1 deletion src/common/FileChooser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class FileChooser {
/**
* Closes the file chooser without selecting any files.
*/
async cancel(): Promise<void> {
cancel() {
assert(
!this._handled,
'Cannot cancel FileChooser which is already handled!'
Expand Down
8 changes: 7 additions & 1 deletion test/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,13 @@ describe('input tests', function () {
]);
await fileChooser.cancel();
let error = null;
await fileChooser.cancel().catch((error_) => (error = error_));

try {
fileChooser.cancel();
} catch (error_) {
error = error_;
}

expect(error.message).toBe(
'Cannot cancel FileChooser which is already handled!'
);
Expand Down

0 comments on commit 2ba61e0

Please sign in to comment.