diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js
index f1520eb5b22..3fde471cc40 100644
--- a/app/assets/javascripts/discourse/app/components/composer-editor.js
+++ b/app/assets/javascripts/discourse/app/components/composer-editor.js
@@ -799,22 +799,24 @@ export default Component.extend({
if (matchingPlaceholder) {
const match = matchingPlaceholder[index];
- if (!match) {
- return;
+
+ if (match) {
+ const replacement = match.replace(
+ imageScaleRegex,
+ ``
+ );
+
+ this.appEvents.trigger(
+ "composer:replace-text",
+ matchingPlaceholder[index],
+ replacement,
+ { regex: imageScaleRegex, index }
+ );
}
-
- const replacement = match.replace(
- imageScaleRegex,
- ``
- );
-
- this.appEvents.trigger(
- "composer:replace-text",
- matchingPlaceholder[index],
- replacement,
- { regex: imageScaleRegex, index }
- );
}
+
+ e.preventDefault();
+ return;
});
},
diff --git a/test/javascripts/acceptance/composer-test.js b/test/javascripts/acceptance/composer-test.js
index 5a30d17c557..9d246cdd3ce 100644
--- a/test/javascripts/acceptance/composer-test.js
+++ b/test/javascripts/acceptance/composer-test.js
@@ -750,7 +750,7 @@ QUnit.test("Image resizing buttons", async assert => {
let uploads = [
// 0 Default markdown with dimensions- should work
- "",
+ "",
// 1 Image with scaling percentage, should work
"",
// 2 image with scaling percentage and a proceeding whitespace, should work
@@ -784,7 +784,8 @@ QUnit.test("Image resizing buttons", async assert => {
);
// Default
- uploads[0] = "";
+ uploads[0] =
+ "";
await click(
find(".button-wrapper[data-image-index='0'] .scale-btn[data-scale='50']")
);