diff --git a/app/assets/javascripts/discourse/app/helpers/emoji.js b/app/assets/javascripts/discourse/app/helpers/emoji.js index 54e5f3faa08..4e0f5ee594f 100644 --- a/app/assets/javascripts/discourse/app/helpers/emoji.js +++ b/app/assets/javascripts/discourse/app/helpers/emoji.js @@ -1,11 +1,9 @@ import { emojiUnescape } from "discourse/lib/text"; import { escapeExpression } from "discourse/lib/utilities"; import { htmlSafe } from "@ember/template"; -import { helper } from "@ember/component/helper"; +import { registerUnbound } from "discourse-common/lib/helpers"; -function emoji(code, options) { +registerUnbound("emoji", function (code, options) { const escaped = escapeExpression(`:${code}:`); return htmlSafe(emojiUnescape(escaped, options)); -} - -export default helper(emoji); +}); diff --git a/app/assets/javascripts/discourse/app/templates/user-selector-autocomplete.hbr b/app/assets/javascripts/discourse/app/templates/user-selector-autocomplete.hbr index 797bd64e352..7a1e11338f4 100644 --- a/app/assets/javascripts/discourse/app/templates/user-selector-autocomplete.hbr +++ b/app/assets/javascripts/discourse/app/templates/user-selector-autocomplete.hbr @@ -5,8 +5,9 @@ {{avatar user imageSize="tiny"}} {{format-username user.username}} - {{user.name}} - {{decorate-username-selector user.username}} + {{#if user.status}} + {{emoji user.status.emoji title=user.status.description}} + {{/if}} {{/each}} diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-editor-mentions-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-editor-mentions-test.js index ea6f29bc0e9..39bbbb6949d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-editor-mentions-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-editor-mentions-test.js @@ -1,6 +1,10 @@ import { test } from "qunit"; import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers"; -import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; +import { + acceptance, + exists, + query, +} from "discourse/tests/helpers/qunit-helpers"; import { setCaretPosition } from "discourse/lib/utilities"; acceptance("Composer - editor mentions", function (needs) { @@ -16,6 +20,10 @@ acceptance("Composer - editor mentions", function (needs) { name: "Some User", avatar_template: "https://avatars.discourse.org/v3/letter/t/41988e/{size}.png", + status: { + emoji: "tooth", + description: "off to dentist", + }, }, { username: "user2", @@ -104,4 +112,20 @@ acceptance("Composer - editor mentions", function (needs) { "should replace mention correctly" ); }); + + test("shows status on search results when mentioning a user", async function (assert) { + await visit("/"); + await click("#create-topic"); + + // emulate typing in "abc @u" + const editor = query(".d-editor-input"); + await fillIn(".d-editor-input", "@"); + await setCaretPosition(editor, 5); + await triggerKeyEvent(".d-editor-input", "keyup", "@"); + await fillIn(".d-editor-input", "@u"); + await setCaretPosition(editor, 6); + await triggerKeyEvent(".d-editor-input", "keyup", "U"); + + assert.ok(exists(".autocomplete .emoji[title='off to dentist']")); + }); });