Skip to content

A platform for community discussion. Free, open, simple.

FIX: Fixed edit category description redirecting without saving (#7192)

Tim Lange22c75e1c0499
diff --git a/app/assets/javascripts/discourse/components/edit-category-general.js.es6 b/app/assets/javascripts/discourse/components/edit-category-general.js.es6
index e5faf9b0d56..52fa673c81f 100644
--- a/app/assets/javascripts/discourse/components/edit-category-general.js.es6
+++ b/app/assets/javascripts/discourse/components/edit-category-general.js.es6
@@ -94,7 +94,7 @@ export default buildCategoryPanel("general", {
actions: {
showCategoryTopic() {
- DiscourseURL.routeTo(this.get("category.topic_url"));
+ window.open(this.get("category.topic_url"), "_blank").focus();
return false;
}
}
diff --git a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
index 03ae8badf4f..5f0720e838e 100644
--- a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
+++ b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
@@ -38,7 +38,7 @@
{{/if}}
{{#if category.topic_url}}
<br>
- {{d-button class="btn-default" action=(action "showCategoryTopic") icon="pencil-alt" label="category.change_in_category_topic"}}
+ {{d-button class="btn-default edit-category-description" action=(action "showCategoryTopic") icon="pencil-alt" label="category.change_in_category_topic"}}
{{/if}}
</section>
{{/if}}
diff --git a/test/javascripts/acceptance/category-edit-test.js.es6 b/test/javascripts/acceptance/category-edit-test.js.es6
index 7a772ebdcef..968fb58f572 100644
--- a/test/javascripts/acceptance/category-edit-test.js.es6
+++ b/test/javascripts/acceptance/category-edit-test.js.es6
@@ -40,6 +40,21 @@ QUnit.test("Editing the category", async assert => {
);
});
+QUnit.test("Edit the description without loosing progress", async assert => {
+ let win = { focus: function() {} };
+ let windowOpen = sandbox.stub(window, "open").returns(win);
+ sandbox.stub(win, "focus");
+
+ await visit("/c/bug");
+
+ await click(".edit-category");
+ await click(".edit-category-description");
+ assert.ok(
+ windowOpen.calledWith("/t/category-definition-for-bug/2", "_blank"),
+ "opens the category topic in a new tab"
+ );
+});
+
QUnit.test("Error Saving", async assert => {
await visit("/c/bug");