From e25578d702791bac80b431acd450cc53b6c39a3c Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 26 Aug 2024 14:25:31 +1000 Subject: [PATCH] FIX: when replacing text in composer maintain history (#28537) Replacing value in the composer will not maintain history, this migrates us to the new pattern used throughout this file --- .../discourse/app/mixins/textarea-text-manipulation.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/mixins/textarea-text-manipulation.js b/app/assets/javascripts/discourse/app/mixins/textarea-text-manipulation.js index 66b38af04b2..84fcff21eb1 100644 --- a/app/assets/javascripts/discourse/app/mixins/textarea-text-manipulation.js +++ b/app/assets/javascripts/discourse/app/mixins/textarea-text-manipulation.js @@ -152,10 +152,11 @@ export default Mixin.create({ i++; return i === opts.index ? newVal : match; }); - this.set("value", newValue); + + this._insertAt(0, val.length, newValue); } else { - // Replace value (side effect: cursor at the end). - this.set("value", val.replace(oldVal, newVal)); + const replacedValue = val.replace(oldVal, newVal); + this._insertAt(0, val.length, replacedValue); } if (