From 6360d3d4e7d9a7043848d01f1e9913e4e205a493 Mon Sep 17 00:00:00 2001 From: jbrw Date: Thu, 4 Nov 2021 17:26:21 -0400 Subject: [PATCH] FIX: ensure required_tag_group_name is null if no value present (#14796) * FIX: ensure required_tag_group_name is null if no value present If the array was present but empty `required_tag_group_name` would be set to undefined, which would then be removed from the payload of the remote request. Addming the length check ensures the value is set to null, which is sent as an empty value (which the backend sees, and can remove it and persist the change on the Category object). --- app/assets/javascripts/discourse/app/models/category.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/models/category.js b/app/assets/javascripts/discourse/app/models/category.js index c2694e88fa6..17a377e019b 100644 --- a/app/assets/javascripts/discourse/app/models/category.js +++ b/app/assets/javascripts/discourse/app/models/category.js @@ -221,9 +221,10 @@ const Category = RestModel.extend({ ? this.allowed_tag_groups : null, allow_global_tags: this.allow_global_tags, - required_tag_group_name: this.required_tag_groups - ? this.required_tag_groups[0] - : null, + required_tag_group_name: + this.required_tag_groups && this.required_tag_groups.length > 0 + ? this.required_tag_groups[0] + : null, min_tags_from_required_group: this.min_tags_from_required_group, sort_order: this.sort_order, sort_ascending: this.sort_ascending,