DEV: setTextareaSelection helper (#7609)

This commit is contained in:
Joffrey JAFFEUX
2019-05-27 16:33:27 +02:00
committed by GitHub
parent 42c82d544e
commit 669bfaba30
4 changed files with 16 additions and 9 deletions
@@ -777,11 +777,6 @@ composerTestCase("replace-text event for composer", async function(assert) {
}
];
function setSelection(textarea, [start, len]) {
textarea.selectionStart = start;
textarea.selectionEnd = start + len;
}
function getSelection(textarea) {
const start = textarea.selectionStart;
const end = textarea.selectionEnd;
@@ -802,13 +797,14 @@ composerTestCase("replace-text event for composer", async function(assert) {
assert.ok(document.activeElement === textarea);
assert.ok(textarea.value === BEFORE);
setSelection(textarea, CASE.before);
const [start, len] = CASE.before;
setTextareaSelection(textarea, start, start + len);
assert.ok(document.activeElement === textarea);
this.container
.lookup("app-events:main")
.trigger("composer:replace-text", "green", "yellow", {forceFocus: true});
.trigger("composer:replace-text", "green", "yellow", { forceFocus: true });
assert.ok(document.activeElement === textarea);