mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Navigate to search result url on click (#24414)
Broken in https://github.com/discourse/discourse/pull/24393
This commit is contained in:
parent
69464cbbe2
commit
8db0eb2afd
@ -23,6 +23,9 @@ export default class Types extends Component {
|
||||
|
||||
@action
|
||||
onClick(event) {
|
||||
if (wantsNewWindow(event)) {
|
||||
return;
|
||||
}
|
||||
this.routeToSearchResult(event);
|
||||
}
|
||||
|
||||
@ -33,6 +36,8 @@ export default class Types extends Component {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
} else if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.routeToSearchResult(event);
|
||||
return false;
|
||||
}
|
||||
@ -43,12 +48,6 @@ export default class Types extends Component {
|
||||
|
||||
@action
|
||||
routeToSearchResult(event) {
|
||||
if (wantsNewWindow(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
DiscourseURL.routeTo(event.target.href);
|
||||
this.args.closeSearchMenu();
|
||||
}
|
||||
|
@ -534,6 +534,28 @@ acceptance("Search - Glimmer - Authenticated", function (needs) {
|
||||
);
|
||||
});
|
||||
|
||||
test("topic results - topic search scope - clicking a search result navigates to topic url", async function (assert) {
|
||||
await visit("/");
|
||||
await click("#search-button");
|
||||
await fillIn("#search-term", "Development");
|
||||
await triggerKeyEvent(document.activeElement, "keyup", "Enter");
|
||||
|
||||
const firstSearchResult =
|
||||
".search-menu .results li:nth-of-type(1) a.search-link";
|
||||
const firstTopicResultUrl = "/t/development-mode-super-slow/2179";
|
||||
assert.strictEqual(
|
||||
query(firstSearchResult).getAttribute("href"),
|
||||
firstTopicResultUrl
|
||||
);
|
||||
|
||||
await click(firstSearchResult);
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
firstTopicResultUrl,
|
||||
"redirects to clicked search result url"
|
||||
);
|
||||
});
|
||||
|
||||
test("search menu keyboard navigation", async function (assert) {
|
||||
const container = ".search-menu .results";
|
||||
await visit("/");
|
||||
|
Loading…
Reference in New Issue
Block a user