From 2003c69698d99b5d06b52d177255c0521c65b1e7 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 21 Jun 2021 09:57:17 +0100 Subject: [PATCH] Update modal to support different events for hiding and cancelling, and support entry transitions for fixed modals --- packages/bbui/src/Modal/Modal.svelte | 24 +++++++++++++++------ packages/bbui/src/Modal/ModalContent.svelte | 4 ++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/bbui/src/Modal/Modal.svelte b/packages/bbui/src/Modal/Modal.svelte index 12c12e3717..3ed9b93fa5 100644 --- a/packages/bbui/src/Modal/Modal.svelte +++ b/packages/bbui/src/Modal/Modal.svelte @@ -27,9 +27,17 @@ visible = false } + export function cancel() { + if (!visible) { + return + } + dispatch("cancel") + hide() + } + function handleKey(e) { if (visible && e.key === "Escape") { - hide() + cancel() } } @@ -41,7 +49,7 @@ } } - setContext(Context.Modal, { show, hide }) + setContext(Context.Modal, { show, hide, cancel }) @@ -56,15 +64,17 @@
-