FIX: emoji_autocomplete_min_chars failing when not 0

FIX: emoji_autocomplete_min_chars failing when not 0

autocomplete resolving to was causing it to stop working. Instead we have a special const (SKIP) which ensures it will continue to be evaluated and only this instance is skipped.

diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js
index f979d7c..4a45c19 100644
--- a/app/assets/javascripts/discourse/app/components/d-editor.js
+++ b/app/assets/javascripts/discourse/app/components/d-editor.js
@@ -29,6 +29,7 @@ import { emojiUrlFor } from "discourse/lib/text";
 import showModal from "discourse/lib/show-modal";
 import { Promise } from "rsvp";
 import { isTesting } from "discourse-common/config/environment";
+import { SKIP } from "discourse/lib/autocomplete";
 
 // Our head can be a static string or a function that returns a string
 // based on input (like for numbered lists).
@@ -480,7 +481,7 @@ export default Component.extend({
           term = term.toLowerCase();
 
           if (term.length < this.siteSettings.emoji_autocomplete_min_chars) {
-            return resolve([]);
+            return resolve(SKIP);
           }
 
           if (term === "") {
diff --git a/app/assets/javascripts/discourse/app/lib/autocomplete.js b/app/assets/javascripts/discourse/app/lib/autocomplete.js
index eea9f8e..a951683 100644
--- a/app/assets/javascripts/discourse/app/lib/autocomplete.js
+++ b/app/assets/javascripts/discourse/app/lib/autocomplete.js
@@ -9,6 +9,7 @@ import Site from "discourse/models/site";
   @module $.fn.autocomplete
 **/
 
+export const SKIP = "skip";
 export const CANCELLED_STATUS = "__CANCELLED";
 const allowedLettersRegex = /[\s\t\[\{\(\/]/;
 
@@ -352,8 +353,6 @@ export default function(options) {
     });
   }
 
-  const SKIP = "skip";
-
   function dataSource(term, opts) {
     if (prevTerm === term) {
       return SKIP;

GitHub sha: 67a310db

1 Like