mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
FIX: pass topic+category to @-mention user search (#29620)
When replying to a topic, the @-mention userSearch needs the topicId and the categoryId so they can trigger immediately, with sane suggestions. This was broken when the mentions were moved from ComposerEditor to DEditor.
This commit is contained in:
parent
635faaaf59
commit
ac33ecdc8c
|
@ -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);
|
||||
|
|
|
@ -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"]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user