mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 07:52:45 +08: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).
|
||||
this.set("value", val.replace(oldVal, newVal));
|
||||
|
||||
// Restore cursor.
|
||||
this._selectText(newSelection.start, newSelection.end - newSelection.start);
|
||||
if ($("textarea.d-editor-input").is(":focus")) {
|
||||
// Restore cursor.
|
||||
this._selectText(
|
||||
newSelection.start,
|
||||
newSelection.end - newSelection.start
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
_addBlock(sel, text) {
|
||||
|
|
|
@ -804,6 +804,10 @@ composerTestCase("replace-text event for composer", async function(assert) {
|
|||
assert,
|
||||
textarea
|
||||
) {
|
||||
const focusEvent = $.Event("focus");
|
||||
const $input = $('textarea.d-editor-input');
|
||||
$input.trigger(focusEvent);
|
||||
|
||||
this.set("value", BEFORE);
|
||||
await setSelection(textarea, CASE.before);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user