diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js index 8e86af03e4..afae9e0428 100644 --- a/app/assets/javascripts/discourse/app/components/d-editor.js +++ b/app/assets/javascripts/discourse/app/components/d-editor.js @@ -576,11 +576,15 @@ export default Component.extend(TextareaTextManipulation, { return resolve(options); }) - .then((list) => - list.map((code) => { + .then((list) => { + if (list === SKIP) { + return []; + } + + return list.map((code) => { return { code, src: emojiUrlFor(code) }; - }) - ) + }); + }) .then((list) => { if (list.length) { list.push({ label: I18n.t("composer.more_emoji"), term }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js index 367fcf340e..eb551cf2a8 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js @@ -1,9 +1,10 @@ import { acceptance, + exists, normalizeHtml, queryAll, } 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 { 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")); + }); });