fix: tag validation

This commit is contained in:
Timothy J. Baek 2024-03-29 18:00:08 -07:00
parent f96beeee8f
commit 2fbb92aceb

View file

@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher, getContext } from 'svelte'; import { createEventDispatcher, getContext } from 'svelte';
import { tags } from '$lib/stores'; import { tags } from '$lib/stores';
import { toast } from 'svelte-sonner';
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const i18n = getContext('i18n'); const i18n = getContext('i18n');
@ -10,9 +11,14 @@
let tagName = ''; let tagName = '';
const addTagHandler = async () => { const addTagHandler = async () => {
dispatch('add', tagName); tagName = tagName.trim();
tagName = ''; if (tagName !== '') {
showTagInput = false; dispatch('add', tagName);
tagName = '';
showTagInput = false;
} else {
toast.error('Invalid Tag');
}
}; };
</script> </script>