diff --git a/docs/api.md b/docs/api.md index 357f1147791..d88502dfdc4 100644 --- a/docs/api.md +++ b/docs/api.md @@ -2790,7 +2790,6 @@ await fileChooser.accept(['/tmp/myfile.pdf']); - returns: <[Promise]> #### fileChooser.cancel() -- returns: <[Promise]> Closes the file chooser without selecting any files. diff --git a/src/common/FileChooser.ts b/src/common/FileChooser.ts index 34069188247..53fc70b9e25 100644 --- a/src/common/FileChooser.ts +++ b/src/common/FileChooser.ts @@ -75,7 +75,7 @@ export class FileChooser { /** * Closes the file chooser without selecting any files. */ - async cancel(): Promise { + cancel() { assert( !this._handled, 'Cannot cancel FileChooser which is already handled!' diff --git a/test/input.spec.ts b/test/input.spec.ts index d87aa1375f7..9244356333a 100644 --- a/test/input.spec.ts +++ b/test/input.spec.ts @@ -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!' );