From 7a074e6684fc5f547eb54b53a5a3c2362ffd7e35 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Thu, 19 Jan 2023 18:35:59 +1000 Subject: [PATCH] FIX: Do not override channel name when category selected (#19920) --- .../discourse/controllers/create-channel.js | 2 +- plugins/chat/spec/system/create_channel_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/chat/assets/javascripts/discourse/controllers/create-channel.js b/plugins/chat/assets/javascripts/discourse/controllers/create-channel.js index ae2ed12f483..ff24ba44d4d 100644 --- a/plugins/chat/assets/javascripts/discourse/controllers/create-channel.js +++ b/plugins/chat/assets/javascripts/discourse/controllers/create-channel.js @@ -149,7 +149,7 @@ export default class CreateChannelController extends Controller.extend( this.setProperties({ categoryId, category, - name: category?.name || "", + name: this.name || category?.name || "", }); } diff --git a/plugins/chat/spec/system/create_channel_spec.rb b/plugins/chat/spec/system/create_channel_spec.rb index d3d4007d473..a525f09371c 100644 --- a/plugins/chat/spec/system/create_channel_spec.rb +++ b/plugins/chat/spec/system/create_channel_spec.rb @@ -22,6 +22,16 @@ RSpec.describe "Create channel", type: :system, js: true do expect(find(".create-channel-hint")).to have_content(Group[:everyone].name) end + it "does not override channel name if that was already specified" do + visit("/chat") + find(".new-channel-btn").click + fill_in("channel-name", with: "My Cool Channel") + find(".category-chooser").click + find(".category-row[data-value=\"#{category_1.id}\"]").click + + expect(page).to have_field("channel-name", with: "My Cool Channel") + end + context "when category is private" do fab!(:group_1) { Fabricate(:group) } fab!(:private_category_1) { Fabricate(:private_category, group: group_1) } @@ -95,6 +105,7 @@ RSpec.describe "Create channel", type: :system, js: true do name = "Cats" find(".category-chooser").click find(".category-row[data-value=\"#{category_1.id}\"]").click + expect(page).to have_field("channel-name", with: category_1.name) fill_in("channel-name", with: name) fill_in("channel-description", with: "All kind of cute cats") find(".create-channel-modal .create").click