Skip to content

Commit

Permalink
fix: Check for tag name leading and trailing spaces (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
navorite committed Dec 10, 2023
1 parent a829026 commit e41d2a3
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/lib/components/modals/TagsModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@
let tag = defualtNewTag;
$: selectVal === 'createANewTag'
? defualtNewTag
: (tag = {
name: selectVal,
bgColor: $settings.tags[selectVal]?.bgColor ?? 'royalblue',
textColor: $settings.tags[selectVal]?.textColor ?? 'white'
});
$: tag =
selectVal === 'createANewTag'
? defualtNewTag
: {
name: selectVal,
bgColor: $settings.tags[selectVal]?.bgColor ?? 'royalblue',
textColor: $settings.tags[selectVal]?.textColor ?? 'white'
};
$: if (open) {
getStorageItem('tags', {}).then((value) => {
tags = value;
});
} else {
tag = defualtNewTag
tag = defualtNewTag;
}
const dispatch = createEventDispatcher<{ tagSubmit: string }>();
Expand All @@ -43,15 +44,17 @@
class="flex h-full w-full flex-col justify-around gap-2"
on:submit|preventDefault={() => {
if (selectVal === 'createANewTag') {
const tags = $settings.tags;
tags[tag.name] = {
bgColor: tag.bgColor,
textColor: tag.textColor
};
if (tag.name.trim()) {
const tags = $settings.tags;
tags[tag.name] = {
bgColor: tag.bgColor,
textColor: tag.textColor
};

settings.changeSetting('tags', tags);
settings.changeSetting('tags', tags);

dispatch('tagSubmit', tag.name);
dispatch('tagSubmit', tag.name);
}
} else dispatch('tagSubmit', selectVal);

open = false;
Expand Down Expand Up @@ -123,7 +126,7 @@

<button
class="rounded-md bg-primary px-2 py-1 hover:bg-primary-focus disabled:bg-neutral-3/50 disabled:text-neutral-content/50"
disabled={!tag.name.length}>{i18n.getMessage('labelAddTag')}</button
disabled={!tag.name.trim()}>{i18n.getMessage('labelAddTag')}</button
>
</form>
</svelte:fragment>
Expand Down

0 comments on commit e41d2a3

Please sign in to comment.