FIX: Ensure composer also filters tags when searching (#37555)

When editing a topic via the composer, tags with parent tag requirements
weren't appearing in search results, even though the parent tag was
already selected on the topic. When the composer opens for editing, it
was using these serialized string tags. The mini-tag-chooser couldn't
extract tag IDs from strings

This commit fixes that. Also adds a system spec testing the composer and
title header scenarios.
This commit is contained in:
Natalie Tay
2026-02-05 15:03:15 +08:00
committed by GitHub
parent 775cb5f236
commit debac2fd5b
3 changed files with 55 additions and 2 deletions
@@ -989,6 +989,7 @@ export default class Composer extends RestModel {
if (isEdit(opts.action) && this.post) {
const topicProps = this.serialize(_edit_topic_serializer);
topicProps.loading = true;
topicProps.tags = this.topic.tags;
// When editing a shared draft, use its category
if (opts.action === EDIT_SHARED_DRAFT && opts.destinationCategoryId) {
+5 -2
View File
@@ -4009,7 +4009,7 @@ export default {
chunk_size: 20,
bookmarked: null,
bookmarks: [],
tags: ["foo"],
tags: [{ id: 1, name: "foo", slug: "foo" }],
},
"/t/9/1.json": {
post_stream: {
@@ -5805,7 +5805,10 @@ export default {
avatar_template: "/images/avatar.png",
},
},
tags: ["foo", "baz"],
tags: [
{ id: 1, name: "foo", slug: "foo" },
{ id: 2, name: "baz", slug: "baz" },
],
},
"/t/2481/1.json": {
post_stream: {
+49
View File
@@ -263,5 +263,54 @@ describe "Tags", type: :system do
original_tag_ids = draft_data["original_tags"].map { |t| t["id"] }
expect(original_tag_ids).to contain_exactly(tag_one.id, tag_two.id)
end
it "shows child tags when parent tag is selected in topic title editor and composer" do
parent_tag = Fabricate(:tag, name: "cap")
child_tag_approved = Fabricate(:tag, name: "cap-approved")
child_tag_closed = Fabricate(:tag, name: "cap-closed")
child_tag_open = Fabricate(:tag, name: "cap-open")
tag_group =
Fabricate(
:tag_group,
name: "Corrective Action Plans",
parent_tag: parent_tag,
one_per_topic: true,
tags: [child_tag_approved, child_tag_closed, child_tag_open],
)
topic = Fabricate(:topic, user: admin, tags: [parent_tag])
Fabricate(:post, topic: topic, user: admin)
sign_in(admin)
visit topic.url
topic_page.click_topic_edit_title
expect(topic_page).to have_topic_title_editor
mini_tag_chooser.expand
mini_tag_chooser.search("cap-")
expect(mini_tag_chooser).to have_option_name("cap-approved")
expect(mini_tag_chooser).to have_option_name("cap-closed")
expect(mini_tag_chooser).to have_option_name("cap-open")
mini_tag_chooser.collapse_with_escape
topic_page.click_topic_title_cancel_edit
find("#post_1 .post-controls .edit").click
expect(composer).to be_opened
expect(page).to have_css(".mini-tag-chooser", text: "cap")
composer_tag_chooser =
PageObjects::Components::SelectKit.new(".composer-fields .mini-tag-chooser")
composer_tag_chooser.expand
composer_tag_chooser.search("cap-")
expect(composer_tag_chooser).to have_option_name("cap-approved")
expect(composer_tag_chooser).to have_option_name("cap-closed")
expect(composer_tag_chooser).to have_option_name("cap-open")
end
end
end