Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
frankcai opened this issue Mar 25, 2022 · 1 comment
Closed
4 tasks done

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

frankcai opened this issue Mar 25, 2022 · 1 comment
Assignees
Labels
🐛 Bug [ISSUE] Ticket describing something that isn't working

Comments

@frankcai
Copy link

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:

  • Add a tag "test" to an item, save and reopen then try to change any other field and save
  • "test" Tag already exists, try to change any other field and save

Test cases that work:

  • Add a tag "test" to an item and save
  • Add a tag "test" to an item, change any other field and save
  • Remove the "test" tag and save
  • Remove the "test" tag, change any other field and save

Additional info

No response

Please tick the boxes

@frankcai frankcai added the 🐛 Bug [ISSUE] Ticket describing something that isn't working label Mar 25, 2022
@frankcai frankcai changed the title [BUG] Configuration not savable when a single tag exists [BUG] Configuration not saveable when a single tag exists Mar 25, 2022
@Lissy93
Copy link
Owner

Lissy93 commented Mar 27, 2022

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.

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug [ISSUE] Ticket describing something that isn't working
Projects
None yet
Development

No branches or pull requests

2 participants