From 1b4a7f3612eb56f9dde58cb8324254400d60a094 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 17 Apr 2023 21:07:40 +0300 Subject: [PATCH] fix bug when removing process from list --- lab2/src/lib/ProcessList.svelte | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lab2/src/lib/ProcessList.svelte b/lab2/src/lib/ProcessList.svelte index ae083bd..983e21c 100644 --- a/lab2/src/lib/ProcessList.svelte +++ b/lab2/src/lib/ProcessList.svelte @@ -37,6 +37,13 @@ processess = newProcessess selectedAdd = getAvailableProcessess()[0] } + + function removeRow(id) { + processess = processess.filter(row => row != id) + if (selectedAdd == undefined) { + selectedAdd = getAvailableProcessess()[0] + } + }
@@ -52,9 +59,7 @@ icon={TrashCan} iconDescription="Delete" kind="danger-tertiary" - on:click={() => { - processess = processess.filter(row => row != id) - }} + on:click={() => removeRow(id)} />
{/each}