From a9b4f905042181b6de43539381c169920c4cee9e Mon Sep 17 00:00:00 2001 From: Andrew Herron Date: Mon, 18 Nov 2024 11:25:34 +1100 Subject: [PATCH] Fixed user comparison in the fetch function, and sorted the names --- modules/ROOT/examples/live-demos/mentions/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ROOT/examples/live-demos/mentions/index.js b/modules/ROOT/examples/live-demos/mentions/index.js index 330d8ba102..57d75acbe3 100644 --- a/modules/ROOT/examples/live-demos/mentions/index.js +++ b/modules/ROOT/examples/live-demos/mentions/index.js @@ -21,6 +21,7 @@ tinymce.ScriptLoader.loadScripts(['https://cdn.jsdelivr.net/npm/faker@5/dist/fak for (let i = 0; i < 200; i++) { userNames.push(faker.name.findName()); } + userNames.sort((a, b) => a.localeCompare(b)); /* This represents a database of users on the server */ const userDb = {}; @@ -79,7 +80,7 @@ tinymce.ScriptLoader.loadScripts(['https://cdn.jsdelivr.net/npm/faker@5/dist/fak } usersRequest.then((users) => { /* `query.term` is the text the user typed after the '@' */ - users = users.filter((user) => user.name.indexOf(query.term.toLowerCase()) !== -1); + users = users.filter((user) => user.name.toLowerCase().includes(query.term.toLowerCase())) users = users.slice(0, 10);