A platform for community discussion. Free, open, simple.
FIX: prevents error with emoji autocomplete (#16465)
Joffrey JAFFEUX3e0c8d48e9a1
diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.jsindex 8e86af03e4c..afae9e0428e 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.jsindex 367fcf340e4..eb551cf2a82 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"));+ });});