Skip to content

Commit aa612ce

Browse files
feat(cc-search-bar): match text tokens against item id
1 parent 7443c04 commit aa612ce

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/components/cc-search-bar/cc-search-bar.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const KEYWORD_TOKEN_REGEX = /^is:./;
2929
* - keyword tokens (`is:<value>`): an item passes only if every keyword token
3030
* is present in its derived matchers (`is:<itemType>` and explicit `matchers`).
3131
* - text tokens: an item passes only if every text token is `includes`'d in its
32-
* lowercased label.
32+
* lowercased label or its lowercased id.
3333
*
3434
* @param {SearchBarSection[]} sections
3535
* @param {string} value
@@ -54,7 +54,8 @@ function filterSections(sections, value) {
5454
return false;
5555
}
5656
const label = item.label.toLowerCase();
57-
return textTokens.every((token) => label.includes(token));
57+
const id = item.id?.toLowerCase() ?? '';
58+
return textTokens.every((token) => label.includes(token) || id.includes(token));
5859
}),
5960
}))
6061
.filter((section) => section.items.length > 0);

src/components/cc-search-bar/cc-search-bar.types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type SearchBarItemType = 'app' | 'addon' | 'network-group' | 'cke';
55
export interface SearchBarItem {
66
label: string;
77
href: string;
8+
id?: string;
89
itemType?: SearchBarItemType;
910
matchers?: string[];
1011
}

0 commit comments

Comments
 (0)