Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add option to pass final action directly to the wizard so it can be awaited #1043

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/lib/layout/wizard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
export let steps: WizardStepsType;
export let confirmExit = false;
export let finalAction = 'Create';
export let finalMethod: () => Promise<void> = null;

const dispatch = createEventDispatcher();

Expand Down Expand Up @@ -94,11 +95,18 @@
}
} else {
$wizard.nextDisabled = true;
trackEvent('wizard_finish');
dispatch('finish');
setTimeout(() => {
if (finalMethod) {
await finalMethod();
trackEvent('wizard_finish');
$wizard.nextDisabled = false;
}, 2000);
} else {
trackEvent('wizard_finish');
dispatch('finish');

setTimeout(() => {
$wizard.nextDisabled = false;
}, 2000);
}
}
} else {
if (steps.get($wizard.step + 1)?.disabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
});
</script>

<Wizard title="Create project" steps={stepsComponents} on:finish={create} on:exit={onFinish} />
<Wizard title="Create project" steps={stepsComponents} finalMethod={create} on:exit={onFinish} />
Loading