Skip to content

Commit f60df1f

Browse files
committed
fix(web): preserve original settings search labels
1 parent c62cf2d commit f60df1f

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎apps/web/src/components/settings/settingsSearch.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ describe("searchSettings", () => {
7575
scope: "environment-defaults",
7676
});
7777
}
78+
try {
79+
for (const enabled of [false, true]) {
80+
setMergeRequestTerms(enabled);
81+
for (const query of ["pull requests", ...(enabled ? ["merge requests"] : [])]) {
82+
expect(
83+
searchSettings(query).map((item) => item.id),
84+
query,
85+
).toContain("diff-layout");
86+
expect(
87+
searchSettings(query, [
88+
{ id: "requests", title: "Pull requests", to: "/settings/general" },
89+
]),
90+
).toMatchObject([
91+
{ id: "requests", title: enabled ? "Merge requests" : "Pull requests" },
92+
]);
93+
}
94+
}
95+
} finally {
96+
setMergeRequestTerms(false);
97+
}
7898
});
7999

80100
it("hides the Secrets page from nav and search while the secrets feature is disabled", () => {

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,11 +1525,13 @@ export function searchSettings(
15251525
const terms = currentChangeRequestTerms();
15261526

15271527
return settingsForThisPlatform(items)
1528-
.map((item) => ({ ...item, title: formatSettingsSearchTitle(item, terms) }))
1529-
.flatMap((item, index) => {
1528+
.flatMap((originalItem, index) => {
1529+
const item = { ...originalItem, title: formatSettingsSearchTitle(originalItem, terms) };
15301530
const title = normalizeSearchText(item.title);
15311531
const fields = [
15321532
title,
1533+
normalizeSearchText(originalItem.title),
1534+
normalizeSearchText(SETTINGS_SECTION_LABELS[item.to]),
15331535
normalizeSearchText(formatChangeRequestText(SETTINGS_SECTION_LABELS[item.to], terms)),
15341536
...(item.searchTerms ?? []).flatMap((term) => [
15351537
normalizeSearchText(term),

0 commit comments

Comments
 (0)