Tag field: only one tag visible when limited to a specific tag group

Environment

Discourse Version: 3.5.0beta4

Plugin Commit: 7b37b41

Steps to Reproduce

  1. Use input field tag and choose a tag group
  2. Test in wizard
  3. Only one tag or no tags at all are displayed in the input field

JSON attached

staging-forum-cannabisanbauen-net-wizards-1747833617.json (465 Bytes)

Example

https://cablogstaging.discoursehosting.net/w/test-tag-visibility/steps/step_1

Admin access required, I can provide

Logs

nothing in logs

Just so I’m understanding

  1. What do you expect to happen?
  2. What are the settings of the tag group?
  3. What are the other tags in the tag group?
  4. Are there any staff restrictions to the above that may apply?
  1. Expected behavior: All tags from that tag group should appear in the input field

  2. Tag group settings + wizard tag field settings


  3. Other tags:

  4. Tags are set to used by anyone. We have the tag group assigned to a bunch of categories. see for tags indoor and outdoor below. While the set of categories is almost similar, only the outdoor tag actually appears in the wizard while the indoor and other tags don/t


I’ve updated the tag field to support the latest code in core Discourse. Please update and give this another shot.

What commit is “the latest code” ?

Reason for asking:

  • Discourse 3.5.0 beta3 bb5d5b9f and CW 7b37b419 : broken
  • Discourse 3.5.0 beta5 0db6f593 and CW 7b37b419 : works
  • Discourse 3.5.0 beta5 0db6f593 and CW 067fc267 : broken

I’ve updated the plugin again and verified the plugin, and this feature, against the latest commit on main: 43e41cea4403ac9db0c6d3c5ce01dc20d9bbbf90

Broken on CW 07100649 (yesterday) and Discourse beta6 (189e136, yesterday)

Working on CW 7b37b4191 (May 16) and Discourse beta6 (189e136, yesterday)

@angus
Hey angus

Any news on this bug?

The plugin is still broken with respect to this.

By request of @jrgong I have taken another look at this and as I understand CW adds the option to select from specific tag groups).

CW gets the correct tags and fills them into :only_tag_names and then calls super.

However, it leaves the :for_input parameter intact and passes it to super.

There are a few places in the core code where it acts on the mere presence of :for_input. But as I understand, the parameter has served its purpose, so removing it might be good.

It seems that this patch resolves the issue, but I have no idea what I am doing and whether this is causing unwanted side effects.

@angus can you please share your thoughts

diff --git a/lib/custom_wizard/extensions/discourse_tagging.rb b/lib/custom_wizard/extensions/discourse_tagging.rb
index 44f08fd1..7ee85a32 100644
--- a/lib/custom_wizard/extensions/discourse_tagging.rb
+++ b/lib/custom_wizard/extensions/discourse_tagging.rb
@@ -13,6 +13,7 @@ module CustomWizardDiscourseTagging
 
       opts[:only_tag_names] ||= []
       opts[:only_tag_names].push(*filtered_tags)
+      opts.delete(:for_input)
     end
 
     super

I’ll take another look at this today.

1 Like

I can’t repro any issues with this functionality. This is a video of me using a tag group to filter a Tag field.

Please prove to me that this is not working on the latest version of the plugin and Discourse :slight_smile:

Latest plugin, latest discourse, unpatched, not working

With the patch I mentioned above, working

[
  {
    "id": "test_tag_visibility",
    "name": "Test tag visibility",
    "save_submissions": true,
    "multiple_submissions": true,
    "restart_on_revisit": true,
    "steps": [
      {
        "id": "step_1",
        "title": "Test tags",
        "fields": [
          {
            "id": "step_1_field_1",
            "label": "Location tag",
            "type": "tag",
            "can_create_tag": false,
            "tag_groups": [
              "Location 🧭"
            ]
          },
          {
            "id": "step_1_field_2",
            "label": "Tag  Test Fläche",
            "type": "tag",
            "limit": "1",
            "can_create_tag": false,
            "tag_groups": [
              "Fläche (nicht editieren!)"
            ]
          }
        ]
      }
    ],
    "actions": []
  }
]

I did briefly suspect the unicode in the tag group names but as I said, the plugin does work with the patch, so apparently that is not an issue.

Database

db6158=# select * from tag_groups where id in (14, 6);
 id |           name            |         created_at         |         updated_at         | parent_tag_id | one_per_topic 
----+---------------------------+----------------------------+----------------------------+---------------+---------------
 14 | Fläche (nicht editieren!) | 2021-07-06 19:51:15.387048 | 2022-01-18 08:48:45.507414 |               | f
  6 | Location ð§­               | 2020-05-29 17:19:14.877568 | 2024-06-24 12:34:04.143395 |               | f
(2 rows)

        
db6158=# select * from tag_group_memberships where tag_group_id in (14,6);
  id  | tag_id | tag_group_id |         created_at         |         updated_at         
------+--------+--------------+----------------------------+----------------------------
  249 |    249 |            6 | 2020-05-29 17:19:14.879973 | 2020-05-29 17:19:14.879973
  250 |    251 |            6 | 2020-05-29 17:19:14.882027 | 2020-05-29 17:19:14.882027
 1944 |    220 |           14 | 2021-07-06 19:51:15.389505 | 2021-07-06 19:51:15.389505
 1945 |    221 |           14 | 2021-07-06 19:51:15.395527 | 2021-07-06 19:51:15.395527
 1946 |    222 |           14 | 2021-07-06 19:51:15.396959 | 2021-07-06 19:51:15.396959
 1947 |   7349 |           14 | 2021-07-06 19:51:15.397916 | 2021-07-06 19:51:15.397916
 1948 |    242 |           14 | 2021-07-06 19:56:05.163484 | 2021-07-06 19:56:05.163484
 1949 |    224 |           14 | 2021-07-06 19:56:05.170746 | 2021-07-06 19:56:05.170746
 1950 |    225 |           14 | 2021-07-06 19:56:05.172636 | 2021-07-06 19:56:05.172636
 1951 |    223 |           14 | 2021-07-06 19:56:05.174232 | 2021-07-06 19:56:05.174232
 1952 |    228 |           14 | 2021-07-06 19:56:05.17557  | 2021-07-06 19:56:05.17557
 1953 |   7350 |           14 | 2021-07-06 19:56:05.196151 | 2021-07-06 19:56:05.196151
 1954 |   7351 |           14 | 2021-07-06 19:56:05.203247 | 2021-07-06 19:56:05.203247
 1955 |   7352 |           14 | 2021-07-06 19:56:05.211    | 2021-07-06 19:56:05.211
 1956 |   7353 |           14 | 2021-07-06 19:56:05.217929 | 2021-07-06 19:56:05.217929
 1957 |   7354 |           14 | 2021-07-06 19:56:05.224907 | 2021-07-06 19:56:05.224907
 1958 |   7355 |           14 | 2021-07-06 19:56:05.232166 | 2021-07-06 19:56:05.232166
 1959 |   7356 |           14 | 2021-07-06 19:56:05.239116 | 2021-07-06 19:56:05.239116
 1960 |   7357 |           14 | 2021-07-06 19:56:05.246227 | 2021-07-06 19:56:05.246227
 1961 |   7358 |           14 | 2021-07-06 19:56:05.253598 | 2021-07-06 19:56:05.253598
 1962 |    226 |           14 | 2021-07-06 19:59:31.758952 | 2021-07-06 19:59:31.758952
 1963 |    227 |           14 | 2021-07-06 19:59:31.762791 | 2021-07-06 19:59:31.762791
 1964 |   7359 |           14 | 2021-07-06 19:59:31.779045 | 2021-07-06 19:59:31.779045
 1965 |   7360 |           14 | 2021-07-06 19:59:31.786101 | 2021-07-06 19:59:31.786101
 1966 |   7361 |           14 | 2021-07-06 19:59:31.792766 | 2021-07-06 19:59:31.792766
 1967 |   7362 |           14 | 2021-07-06 19:59:31.799598 | 2021-07-06 19:59:31.799598
 1968 |   7363 |           14 | 2021-07-06 19:59:31.806182 | 2021-07-06 19:59:31.806182
 1969 |   7364 |           14 | 2021-07-06 19:59:31.813449 | 2021-07-06 19:59:31.813449
 7769 |   7346 |            6 | 2023-05-28 12:35:34.683498 | 2023-05-28 12:35:34.683498
 7770 |   7785 |            6 | 2023-05-28 12:35:34.694618 | 2023-05-28 12:35:34.694618
 7771 |   7786 |            6 | 2023-05-28 12:35:34.699707 | 2023-05-28 12:35:34.699707
 7772 |   7787 |            6 | 2023-05-28 12:35:34.704511 | 2023-05-28 12:35:34.704511
 7773 |   7788 |            6 | 2023-05-28 12:35:34.711    | 2023-05-28 12:35:34.711
(33 rows)

db6158=# select * from tag_group_permissions where tag_group_id in (14,6);
 id  | tag_group_id | group_id | permission_type |         created_at         |         updated_at         
-----+--------------+----------+-----------------+----------------------------+----------------------------
 283 |           14 |        0 |               1 | 2022-01-18 08:48:45.50872  | 2022-01-18 08:48:45.50872
 503 |            6 |        0 |               1 | 2024-06-24 13:14:19.131209 | 2024-06-24 13:14:19.131209
(2 rows)

db6158=# select * from tags where id in (select tag_id from tag_group_memberships where tag_group_id in (14,6));
  id  |   name   |         created_at         |         updated_at         | pm_topic_count | target_tag_id | description | public_topic_count | staff_topic_count 
------+----------+----------------------------+----------------------------+----------------+---------------+-------------+--------------------+-------------------
  227 | 240x240  | 2019-11-18 12:30:35.803709 | 2019-11-18 12:30:35.803709 |              0 |               |             |                  0 |                 0
 7358 | 150x100  | 2021-07-06 19:56:05.249763 | 2021-07-06 19:56:05.249763 |              0 |               |             |                  0 |                 0
 7359 | 110x110  | 2021-07-06 19:59:31.772443 | 2021-07-06 19:59:31.772443 |              0 |               |             |                  0 |                 0
 7362 | 300x300  | 2021-07-06 19:59:31.796011 | 2021-07-06 19:59:31.796011 |              0 |               |             |                  0 |                 0
 7363 | 300x150  | 2021-07-06 19:59:31.802725 | 2021-07-06 19:59:31.802725 |              0 |               |             |                  0 |                 0
 7360 | 200x200  | 2021-07-06 19:59:31.782599 | 2021-07-06 19:59:31.782599 |              0 |               |             |                  1 |                 1
 7354 | 60x40    | 2021-07-06 19:56:05.221359 | 2021-07-06 19:56:05.221359 |              0 |               |             |                  0 |                 1
 7352 | 50x100   | 2021-07-06 19:56:05.207109 | 2021-07-06 19:56:05.207109 |              0 |               |             |                  2 |                 2
 7361 | 200x100  | 2021-07-06 19:59:31.789193 | 2021-07-06 19:59:31.789193 |              0 |               |             |                  1 |                 1
 7353 | 80x60    | 2021-07-06 19:56:05.214447 | 2021-07-06 19:56:05.214447 |              0 |               |             |                  1 |                 1
 7356 | 100x60   | 2021-07-06 19:56:05.235402 | 2021-07-06 19:56:05.235402 |              0 |               |             |                  4 |                 4
  228 | 150x150  | 2019-11-18 12:30:35.808772 | 2019-11-18 12:30:35.808772 |              0 |               |             |                  5 |                 5
 7351 | 90x90    | 2021-07-06 19:56:05.199809 | 2021-07-06 19:56:05.199809 |              0 |               |             |                 28 |                30
  226 | 240x120  | 2019-11-18 12:30:35.798647 | 2019-11-18 12:30:35.798647 |              0 |               |             |                  2 |                 2
  220 | 30x30    | 2019-11-18 12:30:35.664147 | 2019-11-18 12:30:35.664147 |              0 |               |             |                  4 |                 4
 7355 | 90x60    | 2021-07-06 19:56:05.228605 | 2021-07-06 19:56:05.228605 |              0 |               |             |                  5 |                 7
 7357 | 120x90   | 2021-07-06 19:56:05.242683 | 2021-07-06 19:56:05.242683 |              0 |               |             |                  7 |                 8
 7346 | garten   | 2021-06-17 16:04:03.561504 | 2021-06-17 16:04:03.561504 |              0 |               |             |                 22 |                22
 7364 | 150x80   | 2021-07-06 19:59:31.809494 | 2021-07-06 19:59:31.809494 |              0 |               |             |                 10 |                11
 7349 | 50x50    | 2021-07-06 19:51:15.322978 | 2021-07-06 19:51:15.322978 |              0 |               |             |                  8 |                 8
  242 | 120x60   | 2020-01-12 13:33:19.528507 | 2020-01-12 13:33:19.528507 |              0 |               |             |                 54 |                57
 7785 | balkon   | 2023-05-28 12:35:34.689541 | 2023-05-28 12:35:34.689541 |              0 |               |             |                 33 |                33
 7786 | wald     | 2023-05-28 12:35:34.696665 | 2023-05-28 12:35:34.696665 |              0 |               |             |                  0 |                 0
 7787 | spot     | 2023-05-28 12:35:34.70173  | 2023-05-28 12:35:34.70173  |              0 |               |             |                  1 |                 1
 7788 | guerilla | 2023-05-28 12:35:34.708547 | 2023-05-28 12:35:34.708547 |              0 |               |             |                  9 |                11
  221 | 40x40    | 2019-11-18 12:30:35.770384 | 2019-11-18 12:30:35.770384 |              0 |               |             |                 98 |                99
  249 | outdoor  | 2020-04-16 15:19:18.817341 | 2020-04-16 15:19:18.817341 |              0 |               |             |                595 |               605
 7350 | 70x70    | 2021-07-06 19:56:05.186326 | 2021-07-06 19:56:05.186326 |              0 |               |             |                 26 |                28
  222 | 60x60    | 2019-11-18 12:30:35.776553 | 2019-11-18 12:30:35.776553 |              1 |               |             |                341 |               348
  224 | 100x100  | 2019-11-18 12:30:35.787838 | 2019-11-18 12:30:35.787838 |              1 |               |             |                227 |               238
  225 | 120x120  | 2019-11-18 12:30:35.793354 | 2019-11-18 12:30:35.793354 |              0 |               |             |                166 |               171
  223 | 80x80    | 2019-11-18 12:30:35.782308 | 2019-11-18 12:30:35.782308 |              3 |               |             |                368 |               380
  251 | indoor   | 2020-05-29 17:19:14.841627 | 2020-05-29 17:19:14.841627 |              5 |               |             |               2475 |              2586
(33 rows)

Sorry, but the default functionality does work. I’ve tested it again.

I would like @jrgong to test this in isolation on his site if that’s possible and demonstrate that it’s not working there, and perhaps test whether another customisation is interfering.

@richard I hope JR appreciates your doggedness :slight_smile: , but right now my view is that the default functionality of this feature works as described.

Hey guys

I can test test and make a screen recording

@richard can you install the presumed bugged version again so I can give it a shot?

Edit:

I created a new wizard here and for each field I linked the tag group directly: https://cablogstaging.discoursehosting.net/w/tag-group-test-by-jr/
That way, you can check each link for the full list of tags that should be returned in the drop down.

When testing it, the tags are not returned correctly. Maybe some other plugin or setting interfering?

Below is my recording while 2.12.0 0710064 is installed:

CleanShot 2025-06-27 at 14.46.26

We can exchange videos all day, but the basic point remains. If you just have the plugin installed with the latest discourse the functionality works. If it’s not working on your instance we have to find the actual reason it’s not working. Applying a “fix” without knowing the reason would not be a good idea. I will look at your site more closely later today.

Update: Just to check, I created a brand new tag group and tested again, that works! So could it be something in my “legacy” tag groups that is interfering? @richard @angus

Ok, we’re making progress :slight_smile:

So now we need to know the difference between the old tag group and this new one.

It could be, but I have no idea what it would be.

Are there any different settings between the two? Do they look different in the db?

What about the tags themselves. Are they restricted in any way? Do they all actually exist, i.e. those in the group?