From 0fb7c0f7e70ffa578b27a708542bd6640f8d57df Mon Sep 17 00:00:00 2001 From: Mohammed Alamri Date: Wed, 4 Dec 2024 23:24:39 +0300 Subject: [PATCH] add confirm before removing field --- src/lib/form/Form.svelte | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/lib/form/Form.svelte b/src/lib/form/Form.svelte index 1b98964..8c0f8b3 100644 --- a/src/lib/form/Form.svelte +++ b/src/lib/form/Form.svelte @@ -8,6 +8,7 @@ import elements from '$lib/elements'; import { slide } from 'svelte/transition'; import type { Component } from 'svelte'; + import Popover from '$lib/components/Popover.svelte'; // Components import Button from '$lib/components/Button.svelte'; @@ -55,7 +56,7 @@ // Remove field. const removeField = (fieldId: string): void => { - form.activeElement = null; + form.activeElement = null; form.fields = form.fields.filter((f) => f.id !== fieldId); }; @@ -70,7 +71,7 @@ const field = prepareField(event.item.dataset.type); const { newIndex } = event; form.fields = [...form.fields.slice(0, newIndex), field, ...form.fields.slice(newIndex)]; - form.activeElement = form.fields[newIndex]; + form.activeElement = form.fields[newIndex]; }, onRemove(event: SortableEvent) { const { oldDraggableIndex } = event; @@ -92,10 +93,10 @@
-
+
{#if form.fields.length === 0}
@@ -109,19 +110,25 @@
(form.activeElement = field)} > {#if !isPreview.state}
- + + {#snippet trigger()} + + {/snippet} +
+

Remove this field?

+
+
{/if}
@@ -135,7 +142,7 @@
-