UX: Better visibility for context search (#14599)
This commit is contained in:
parent
8b25aaed14
commit
0616a5ac7c
|
@ -480,7 +480,8 @@ createWidget("search-menu-initial-options", {
|
|||
const ctx = service.get("searchContext");
|
||||
|
||||
const content = [];
|
||||
if (attrs.term) {
|
||||
|
||||
if (attrs.term || ctx) {
|
||||
if (ctx) {
|
||||
const term = attrs.term ? `${attrs.term} ` : "";
|
||||
|
||||
|
@ -549,8 +550,9 @@ createWidget("search-menu-initial-options", {
|
|||
}
|
||||
}
|
||||
|
||||
const rowOptions = { withLabel: true };
|
||||
content.push(this.defaultRow(attrs.term, rowOptions));
|
||||
if (attrs.term) {
|
||||
content.push(this.defaultRow(attrs.term, { withLabel: true }));
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
|
@ -601,6 +603,7 @@ createWidget("search-menu-assistant-item", {
|
|||
category: attrs.category,
|
||||
allowUncategorized: true,
|
||||
recursive: true,
|
||||
link: false,
|
||||
})
|
||||
);
|
||||
} else if (attrs.tag) {
|
||||
|
|
|
@ -117,6 +117,13 @@ acceptance("Search - Anonymous", function (needs) {
|
|||
|
||||
await visit("/tag/important");
|
||||
await click("#search-button");
|
||||
|
||||
assert.equal(
|
||||
query(firstResult).textContent.trim(),
|
||||
`${I18n.t("search.in")} test`,
|
||||
"contenxtual tag search is first available option with no term"
|
||||
);
|
||||
|
||||
await fillIn("#search-term", "smth");
|
||||
|
||||
assert.equal(
|
||||
|
@ -134,6 +141,11 @@ acceptance("Search - Anonymous", function (needs) {
|
|||
"category-scoped search is first available option"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
exists(`${firstResult} span.badge-wrapper`),
|
||||
"category badge is a span (i.e. not a link)"
|
||||
);
|
||||
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click("#search-button");
|
||||
|
||||
|
@ -159,6 +171,16 @@ acceptance("Search - Anonymous", function (needs) {
|
|||
await visit("/t/internationalization-localization/280/1");
|
||||
|
||||
await click("#search-button");
|
||||
|
||||
const firstResult =
|
||||
".search-menu .results .search-menu-assistant-item:first-child";
|
||||
|
||||
assert.equal(
|
||||
query(firstResult).textContent.trim(),
|
||||
I18n.t("search.in_this_topic"),
|
||||
"contenxtual topic search is first available option"
|
||||
);
|
||||
|
||||
await fillIn("#search-term", "a proper");
|
||||
await focus("input#search-term");
|
||||
await triggerKeyEvent(".search-menu", "keydown", 40);
|
||||
|
|
Loading…
Reference in New Issue