FIX: prevents error with emoji autocomplete (#16465)
The error would happen when emoji_autocomplete_min_chars site setting is set to anything superior to 0, in this case until we reach the min chars length, emojiSearch would return "skip" and the code was currently expecting an array.
This commit is contained in:
parent
eb5a3cfded
commit
3e0c8d48e9
|
@ -576,11 +576,15 @@ export default Component.extend(TextareaTextManipulation, {
|
||||||
|
|
||||||
return resolve(options);
|
return resolve(options);
|
||||||
})
|
})
|
||||||
.then((list) =>
|
.then((list) => {
|
||||||
list.map((code) => {
|
if (list === SKIP) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.map((code) => {
|
||||||
return { code, src: emojiUrlFor(code) };
|
return { code, src: emojiUrlFor(code) };
|
||||||
})
|
});
|
||||||
)
|
})
|
||||||
.then((list) => {
|
.then((list) => {
|
||||||
if (list.length) {
|
if (list.length) {
|
||||||
list.push({ label: I18n.t("composer.more_emoji"), term });
|
list.push({ label: I18n.t("composer.more_emoji"), term });
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import {
|
import {
|
||||||
acceptance,
|
acceptance,
|
||||||
|
exists,
|
||||||
normalizeHtml,
|
normalizeHtml,
|
||||||
queryAll,
|
queryAll,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
||||||
|
|
||||||
|
@ -36,4 +37,23 @@ acceptance("Emoji", function (needs) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
needs.settings({
|
||||||
|
emoji_autocomplete_min_chars: 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
test("siteSetting:emoji_autocomplete_min_chars", async function (assert) {
|
||||||
|
await visit("/t/internationalization-localization/280");
|
||||||
|
await click("#topic-footer-buttons .btn.create");
|
||||||
|
|
||||||
|
await fillIn(".d-editor-input", ":s");
|
||||||
|
await triggerKeyEvent(".d-editor-input", "keyup", 40); // ensures a keyup is triggered
|
||||||
|
|
||||||
|
assert.notOk(exists(".autocomplete.ac-emoji"));
|
||||||
|
|
||||||
|
await fillIn(".d-editor-input", ":sw");
|
||||||
|
await triggerKeyEvent(".d-editor-input", "keyup", 40); // ensures a keyup is triggered
|
||||||
|
|
||||||
|
assert.ok(exists(".autocomplete.ac-emoji"));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue