FIX: improves handling of filter with invalid tag chars (#17640)

Tags mixin is already filtering a lot of data from the user submitted filter in `createContentFromInput()` which can lead to sk receiving an empty filter while the input actually has a value.
This commit is contained in:
Joffrey JAFFEUX
2022-07-25 12:00:52 +02:00
committed by GitHub
parent 1f5682b7d7
commit 43b8cfeae3
3 changed files with 37 additions and 16 deletions

View File

@@ -25,6 +25,10 @@ export default Mixin.create({
allowAnyTag: reads("site.can_create_tag"),
validateCreate(filter, content) {
if (!filter.length) {
return;
}
const maximum = this.selectKit.options.maximum;
if (maximum && makeArray(this.value).length >= parseInt(maximum, 10)) {
this.addError(
@@ -42,18 +46,6 @@ export default Mixin.create({
return false;
}
if (
!filter.length ||
this.get("siteSettings.max_tag_length") < filter.length
) {
this.addError(
I18n.t("select_kit.invalid_selection_length", {
count: `[1 - ${this.get("siteSettings.max_tag_length")}]`,
})
);
return false;
}
const toLowerCaseOrUndefined = (string) => {
return isEmpty(string) ? undefined : string.toLowerCase();
};