Lissy93 / dashy

🚀 A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
https://dashy.to
MIT License
18.24k stars 1.38k forks source link

[BUG] Configuration not saveable when a single tag exists #575

Closed frankcai closed 2 years ago

frankcai commented 2 years ago

Environment

Self-Hosted (Docker)

Version

2.0.5

Describe the problem

This error is similar to #430 though not quite the same. In some cases when theres a single tag set in an item saving doesn't work. Further below i've described cases where it works and doesn't work.

In the console there is the following error when trying to save: image

Test cases that fail to save:

Test cases that work:

Additional info

No response

Please tick the boxes

Lissy93 commented 2 years ago

Thanks for the really clear test cases.

Looks like a type error, after the second save the tags are an array, so str.split is throwing an error.

https://github.com/Lissy93/dashy/blob/b51935f04976a56a27ecd3cd3124766f7148bfd0/src/components/InteractiveEditor/EditItem.vue#L234-L237

So I something like this should work

const strToTags = (str) => { 
- const tagArr = str.split(','); 
+ const tagArr = (typeof tags === 'string') ? tags.split(',') : tags;
  return tagArr.map((tag) => tag.trim().toLowerCase().replace(/[^a-z0-9]+/, '')); 
}; 

I'll test it out, and will submit a fix for this as part of #557 and update you when mreged.