From 8aa26b77edbce6b041d5bd82c022823a4bfa930f Mon Sep 17 00:00:00 2001 From: x032205 Date: Tue, 1 Jul 2025 13:11:15 -0400 Subject: [PATCH] Fix check --- .../v2/HighlightText/HighlightText.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/v2/HighlightText/HighlightText.tsx b/frontend/src/components/v2/HighlightText/HighlightText.tsx index 7f7bd6bee..3ce7c8f19 100644 --- a/frontend/src/components/v2/HighlightText/HighlightText.tsx +++ b/frontend/src/components/v2/HighlightText/HighlightText.tsx @@ -18,19 +18,21 @@ export const HighlightText = ({ const escapedSearchTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const regex = new RegExp(escapedSearchTerm, "gi"); - for (const match of text.matchAll(regex)) { - if (match.index > lastIndex) { - parts.push({text.substring(lastIndex, match.index)}); + text.replace(regex, (match: string, offset: number) => { + if (offset > lastIndex) { + parts.push({text.substring(lastIndex, offset)}); } parts.push( - - {match[0]} + + {match} ); - lastIndex = match.index + match[0].length; - } + lastIndex = offset + match.length; + + return match; + }); if (lastIndex < text.length) { parts.push({text.substring(lastIndex)});