Skip to content

Commit f34b773

Browse files
sudhirjadhav18Sudhir Jadhavlexasq
authored
fix(typeahead): change highlight logic (#6764)
change in the highlight method to fix behaviour during search results. #6760 Co-authored-by: Sudhir Jadhav <[email protected]> Co-authored-by: Alexey Umanskiy <[email protected]>
1 parent e89ca9e commit f34b773

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/typeahead/typeahead-container.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ export class TypeaheadContainerComponent implements OnDestroy {
266266
// Replaces the capture string with the same string inside of a "strong" tag
267267
if (typeof query === 'object') {
268268
const queryLen: number = query.length;
269+
const PLACEHOLDER_CHAR = '\u2063'; // Invisible Separator
270+
const STRONG_PLACEHOLDER_COUNT = 17; // 8 + 9: strong tag length (opening and closing)
269271
for (let i = 0; i < queryLen; i += 1) {
270272
// query[i] is already latinized and lower case
271273
startIdx = itemStrHelper.indexOf(query[i]);
@@ -275,7 +277,8 @@ export class TypeaheadContainerComponent implements OnDestroy {
275277
`${itemStr.substring(0, startIdx)}<strong>${itemStr.substring(startIdx, startIdx + tokenLen)}</strong>` +
276278
`${itemStr.substring(startIdx + tokenLen)}`;
277279
itemStrHelper =
278-
`${itemStrHelper.substring(0, startIdx)}????????${'??'.repeat(tokenLen)}??????????` +
280+
`${itemStrHelper.substring(0, startIdx)}`+
281+
`${PLACEHOLDER_CHAR.repeat(STRONG_PLACEHOLDER_COUNT + tokenLen)}`+
279282
`${itemStrHelper.substring(startIdx + tokenLen)}`;
280283
}
281284
}

0 commit comments

Comments
 (0)