fix(notification): on:close should be cancellable (#1379)

Fixes #927
This commit is contained in:
tlkh40 2022-06-29 21:08:51 +07:00 committed by GitHub
commit 924b6d352e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View file

@ -40,8 +40,14 @@
let timeoutId = undefined;
function close(closeFromTimeout) {
open = false;
dispatch("close", { timeout: closeFromTimeout === true });
const shouldContinue = dispatch(
"close",
{ timeout: closeFromTimeout === true },
{ cancelable: true }
);
if (shouldContinue) {
open = false;
}
}
onMount(() => {

View file

@ -43,8 +43,14 @@
let timeoutId = undefined;
function close(closeFromTimeout) {
open = false;
dispatch("close", { timeout: closeFromTimeout === true });
const shouldContinue = dispatch(
"close",
{ timeout: closeFromTimeout === true },
{ cancelable: true }
);
if (shouldContinue) {
open = false;
}
}
onMount(() => {