From c2b139f8173f12169440666c9ec337356e6a3438 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:19:44 +0000 Subject: [PATCH] fix: enums no longer creatable without elements --- src/lib/elements/forms/inputTags.svelte | 15 +++++++++++---- .../attributes/enum.svelte | 4 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/lib/elements/forms/inputTags.svelte b/src/lib/elements/forms/inputTags.svelte index 93d31f8ac2..82528258e4 100644 --- a/src/lib/elements/forms/inputTags.svelte +++ b/src/lib/elements/forms/inputTags.svelte @@ -10,9 +10,11 @@ export let autofocus = false; export let disabled = false; export let readonly = false; + export let required = false; let value = ''; let element: HTMLInputElement; + let hiddenEl: HTMLInputElement; let error: string; onMount(() => { @@ -54,11 +56,11 @@ const handleInvalid = (event: Event) => { event.preventDefault(); - if (element.validity.valueMissing) { + if (hiddenEl.validity.valueMissing) { error = 'This field is required'; return; } - error = element.validationMessage; + error = hiddenEl.validationMessage; }; $: if (value) { @@ -67,6 +69,12 @@ +
@@ -98,8 +106,7 @@ bind:value bind:this={element} on:keydown={handleInput} - on:blur={addValue} - on:invalid={handleInvalid} /> + on:blur={addValue} />
{#if error} diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/enum.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/enum.svelte index 52a45d972b..e61b3c0304 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/enum.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/enum.svelte @@ -40,6 +40,7 @@ default: data.default } = selectedAttribute); } + $: if (data.required || data.array) { data.default = null; } @@ -50,7 +51,8 @@ label="Elements" bind:tags={data.elements} placeholder="Add elements here" - readonly={!!selectedAttribute} /> + readonly={!!selectedAttribute} + required />