# タググループを親から編集すると、誤ったタグ付けが可能になります

**URL:** https://meta.discourse.org/t/editing-topics-with-tag-groups-from-parents-allows-incorrect-tagging/263968
**Category:** Bug
**Tags:** tags
**Created:** [2023 年 5 月 5 日午後 1:07 UTC](https://meta.discourse.org/t/editing-topics-with-tag-groups-from-parents-allows-incorrect-tagging/263968 "2023-05-05T13:07:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sterretje](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@sterretje](https://meta.discourse.org/u/sterretje)
#### Post date: [2023 年 5 月 5 日午後 1:07 UTC](https://meta.discourse.org/t/editing-topics-with-tag-groups-from-parents-allows-incorrect-tagging/263968/1 "2023-05-05T13:07:39Z")

</div>

こんにちは

[Set up structured tagging with tag groups and category tag restrictions](https://meta.discourse.org/t/set-up-structured-tagging-with-tag-groups-and-category-tag-restrictions/48260) を参考にしています。

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/5/6/756e2f95afb99fe2d3375d844ef9590ab00dcaf2.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/0/6/1/06132b15605b310a914be47d23a1b085eb37d711.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/6/4/e64a1f138bd2488034f06fb208c57413c9d8aaeb.png)

**1)** 新しいトピックを作成して送信すると、期待どおりに動作します。  
 ![image](https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/optimized/4X/f/f/0/ff0fc722d9a7a9d213044dc01767271b439b1844_2_690x53.png)

**2)** トピックの編集でメーカーを変更し（モデルはそのまま）、送信すると、両方の親タグが存在します。これは送信されるべきではありませんでした。  
 ![image](https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/optimized/4X/a/2/5/a25c2c09d660ed935a4eb9e524f472f53ae93c64_2_690x53.png)

**3)** トピックの編集でモデルを削除し、送信すると、両方の親タグのみが存在します。これも送信されるべきではありませんでした。  
 ![image](https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/optimized/4X/0/e/d/0ed22acf1edc3a71811e7260665b0bd1a7f2dec8_2_690x53.png)

コンポーザーを使用してトピックを編集しても、トピックタイトルの横にある黒い鉛筆を使用してトピックを編集しても、どちらの場合も正しくない動作が発生します。

コンポーザーを使用してタグを追加する場合、モデルグループの両方から選択できるようになりました。期待どおり、1つしか選択できません。これは、黒い鉛筆を使用してトピックを編集する場合にも当てはまる可能性があります。

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/d/a/1daacc318f7d468d57af7aa496be2844fb319cbd.png)

---

<div class="post-metadata">

### Author: ![saquetim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saquetim/32/116400_2.png) [@saquetim](https://meta.discourse.org/u/saquetim)
#### Post date: [2023 年 5 月 15 日午後 8:39 UTC](https://meta.discourse.org/t/editing-topics-with-tag-groups-from-parents-allows-incorrect-tagging/263968/6 "2023-05-15T20:39:33Z")

</div>

この問題は、以下のリンクで解決されるはずです。

> <https://github.com/discourse/discourse/pull/21490>
>
> \# FIX: Displaying the wrong number of minimum tags in the composer
> 
> When the m…inimum number of tags set for the category is larger than the minimum number of tags set in the category tag-groups, the composer was displaying the wrong value.
> 
> This commit fixes the value displayed in the composer to show the max value between the required for the category and the tag-groups set for the category.
> 
> This bug was reported on Meta in https://meta.discourse.org/t/tags-from-multiple-tag-groups-required-only-suggest-select-at-least-one-tag/263817
> 
> \# FIX: Limiting tags to categories not working as expected
> When a category was restricted to a tag group A, which was set to only allow
> one tag from the group per topic, selecting a tag belonging only to A returned
> other tags from A that also belonged to other group/s (if any).
> 
> Example:
> 
> Tag group A: alpha, beta, gamma, epsilon, delta
> Tag group B: alpha, beta, gamma
> 
> Both tag groups set to only allow one tag from the group per topic.
> 
> If Category 1 was set to only allow tags from the tag group A, and the first tag
> selected was epsilon, then, because they also belonged to tag group B, the tags
> alpha, beta, and gamma were still returned as valid options when they should not be.
> 
> This commit ensures that once a tag from a tag group that restricts its tags to
> one per topic is selected, no other tag from this group is returned.
> 
> This bug was reported on Meta in https://meta.discourse.org/t/limiting-tags-to-categories-not-working-as-expected/263143.
> 
> \# FIX: Moving topics does not prompt to add required tag for new category
> When a topic was moved from a category to another, the tag requirements
> of the new category were not being checked.
> 
> This allowed a topic to be created and moved to a category:
> 
> \- that limited the tags to a tag group, with the topic containing tags
> not allowed.
> \- that required n tags from a tag group, with the topic not containing
> the required tags.
> 
> This bug was reported on Meta in https://meta.discourse.org/t/moving-tagged-topics-does-not-prompt-to-add-required-tag-for-new-category/264138.
> 
> \# FIX: Editing topics with tag groups from parents allows incorrect tagging
> 
> When there was a combination between parent tags defined in a tag group
> set to allow only one tag from the group per topic, and other tag groups
> relying on this restriction to combine the children tag types with the
> parent tag, editing a topic could allow the user to insert an invalid
> combination of these tags.
> 
> Example:
> 
> Automakers tag group: landhover, toyota
> - group set to limit one tag from the group per topic
> 
> Toyota models group: land-cruiser, hilux, corolla
> 
> Landhover models group: evoque, defender, discovery
> 
> If a topic was initially setup with the tags toyota, land-cruiser it was
> possible to edit it removing the tag toyota and adding the tag landhover
> and other landhover model tag like evoque for example.
> 
> In this case the topic would end up with the tags toyota, land-cruiser,
> landhover, evoque because Discourse will automatically insert the
> missing parent tag toyota when it detects the tag land-cruiser.
> 
> This combination of tags would violate the restriction specified in
> the Automakers tag group resulting in an invalid combination of tags.
> 
> This commit enforces that the "one tag from the group per topic"
> restriction is verified before updating the topic tags and also
> make sure the verification check the compatibility of parent tags that
> would be automatically inserted.
> 
> After the changes the user will receive an error similar to:
> The tags land-cruiser, landhover cannot be used simultaneously.
> Please include only one of them.
> 
> This bug was reported on Meta in https://meta.discourse.org/t/editing-topics-with-tag-groups-from-parents-allows-incorrect-tagging/263968.

---

<div class="post-metadata">

### Author: ![sterretje](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@sterretje](https://meta.discourse.org/u/sterretje)
#### Post date: [2023 年 5 月 16 日午前 8:37 UTC](https://meta.discourse.org/t/editing-topics-with-tag-groups-from-parents-allows-incorrect-tagging/263968/7 "2023-05-16T08:37:34Z")

</div>

この修正は期待される結果でテストされました 👍

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2023 年 5 月 16 日午前 8:40 UTC](https://meta.discourse.org/t/editing-topics-with-tag-groups-from-parents-allows-incorrect-tagging/263968/8 "2023-05-16T08:40:49Z")

</div>


