diff --git a/packages/bridge-ui/src/components/modals/NoticeModal.svelte b/packages/bridge-ui/src/components/modals/NoticeModal.svelte index 65b15e44826..ff89da58930 100644 --- a/packages/bridge-ui/src/components/modals/NoticeModal.svelte +++ b/packages/bridge-ui/src/components/modals/NoticeModal.svelte @@ -21,6 +21,11 @@ noShowAgainCheckbox = noShowAgainStorage; }); + function closeAndContinue() { + show = false; + onConfirm?.(noShowAgainCheckbox); + } + function onConfirmNotice() { if (noShowAgainCheckbox) { // If checkbox is checked, store it in localStorage so @@ -29,9 +34,19 @@ noShowAgainStorage = true; } - show = false; + closeAndContinue(); + } - onConfirm?.(noShowAgainCheckbox); + // It could happen that the modal is being opened via prop, but the user + // already opted out of seeing the message (we have localStorage set). + // In that case, we still want to run the onConfirm callback, which contains + // the next steps in the flow, also setting the prop back to false + // (could be bound to the parent) + // TODO: use promises here. API to open the modal should return a promise + // which resolves when the user clicks on confirm. If noShowAgain is set + // to true, the promise should resolve immediately. + $: if (show && noShowAgainStorage) { + closeAndContinue(); }