mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: don't steal focus when text in editor is replaced (#6712)
This commit is contained in:
parent
503ae1829f
commit
142361d6da
@ -676,8 +676,13 @@ export default Ember.Component.extend({
|
|||||||
// Replace value (side effect: cursor at the end).
|
// Replace value (side effect: cursor at the end).
|
||||||
this.set("value", val.replace(oldVal, newVal));
|
this.set("value", val.replace(oldVal, newVal));
|
||||||
|
|
||||||
// Restore cursor.
|
if ($("textarea.d-editor-input").is(":focus")) {
|
||||||
this._selectText(newSelection.start, newSelection.end - newSelection.start);
|
// Restore cursor.
|
||||||
|
this._selectText(
|
||||||
|
newSelection.start,
|
||||||
|
newSelection.end - newSelection.start
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_addBlock(sel, text) {
|
_addBlock(sel, text) {
|
||||||
|
@ -804,6 +804,10 @@ composerTestCase("replace-text event for composer", async function(assert) {
|
|||||||
assert,
|
assert,
|
||||||
textarea
|
textarea
|
||||||
) {
|
) {
|
||||||
|
const focusEvent = $.Event("focus");
|
||||||
|
const $input = $('textarea.d-editor-input');
|
||||||
|
$input.trigger(focusEvent);
|
||||||
|
|
||||||
this.set("value", BEFORE);
|
this.set("value", BEFORE);
|
||||||
await setSelection(textarea, CASE.before);
|
await setSelection(textarea, CASE.before);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user