Skip to content

Commit

Permalink
Merge pull request #205 from appwrite/fix-enums-creatable-without-elems
Browse files Browse the repository at this point in the history
Fix: Attribute enums creatable without elements
  • Loading branch information
TorstenDittmann committed Jan 10, 2023
2 parents 2cdf03d + c2b139f commit 16d8faf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/lib/elements/forms/inputTags.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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) {
Expand All @@ -67,6 +69,12 @@
</script>

<FormItem>
<input
class="u-hide"
bind:this={hiddenEl}
value={tags.join(',')}
{required}
on:invalid={handleInvalid} />
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
<div class="input-text-wrapper">
<div class="tags-input">
Expand Down Expand Up @@ -98,8 +106,7 @@
bind:value
bind:this={element}
on:keydown={handleInput}
on:blur={addValue}
on:invalid={handleInvalid} />
on:blur={addValue} />
</div>
</div>
{#if error}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
default: data.default
} = selectedAttribute);
}
$: if (data.required || data.array) {
data.default = null;
}
Expand All @@ -50,7 +51,8 @@
label="Elements"
bind:tags={data.elements}
placeholder="Add elements here"
readonly={!!selectedAttribute} />
readonly={!!selectedAttribute}
required />
<InputSelect
id="default"
label="Default value"
Expand Down

0 comments on commit 16d8faf

Please sign in to comment.