diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js index b8e6362d31e..0e1ed221c65 100644 --- a/app/assets/javascripts/discourse/app/components/d-editor.js +++ b/app/assets/javascripts/discourse/app/components/d-editor.js @@ -484,8 +484,8 @@ export default class DEditor extends Component { destroyUserStatuses(); return userSearch({ term, - topicId: this.topic?.id, - categoryId: this.topic?.category_id || this.composer?.categoryId, + topicId: this.topicId, + categoryId: this.categoryId, includeGroups: true, }).then((result) => { initUserStatusHtml(getOwner(this), result.users); 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 08e8b860fb5..ac0c64f2bd1 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,7 @@ import { click, visit } from "@ember/test-helpers"; import { test } from "qunit"; import { setCaretPosition } from "discourse/lib/utilities"; +import topicFixtures from "discourse/tests/fixtures/topic"; import { acceptance, fakeTime, @@ -9,6 +10,7 @@ import { queryAll, simulateKeys, } from "discourse/tests/helpers/qunit-helpers"; +import { cloneJSON } from "discourse-common/lib/object"; acceptance("Composer - editor mentions", function (needs) { let clock = null; @@ -24,6 +26,11 @@ acceptance("Composer - editor mentions", function (needs) { needs.hooks.afterEach(() => clock?.restore()); needs.pretender((server, helper) => { + server.get("/t/11557.json", () => { + const topicFixture = cloneJSON(topicFixtures["/t/130.json"]); + topicFixture.id = 11557; + return helper.response(topicFixture); + }); server.get("/u/search/users", () => { return helper.response({ users: [ @@ -144,4 +151,19 @@ acceptance("Composer - editor mentions", function (needs) { ["foo", "user_group", "user", "user2"] ); }); + + test("shows users immediately when @ is typed in a reply", async function (assert) { + await visit("/"); + await click(".topic-list-item .title"); + await click(".btn-primary.create"); + + await simulateKeys(".d-editor-input", "abc @"); + + assert.deepEqual( + [...document.querySelectorAll(".ac-user .username")].map( + (e) => e.innerText + ), + ["user_group", "user", "user2", "foo"] + ); + }); });