From 351353383b38a523837608b9064304c3a53d3204 Mon Sep 17 00:00:00 2001 From: Fabian Blank Date: Mon, 28 Aug 2023 16:58:59 +0200 Subject: [PATCH 1/2] filter out words with 0 length for regex -> leading to invalid regex --- frontend/src/js/tooltip/Tooltip.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/js/tooltip/Tooltip.tsx b/frontend/src/js/tooltip/Tooltip.tsx index ba370e7345..bfbf5247a4 100644 --- a/frontend/src/js/tooltip/Tooltip.tsx +++ b/frontend/src/js/tooltip/Tooltip.tsx @@ -188,10 +188,12 @@ const Tooltip = () => { (state) => state.tooltip.toggleAdditionalInfos, ); - const highlightRegex = useMemo( - () => (words.length > 0 ? new RegExp(words.join("|"), "gi") : null), - [words], - ); + const highlightRegex = useMemo(() => { + console.log("words", words); + return words.length > 0 + ? new RegExp(words.filter((word) => word.length > 0).join("|"), "gi") + : null; + }, [words]); const dispatch = useDispatch(); const onToggleAdditionalInfos = () => dispatch(toggleInfos()); From 3b3ec99cd6f9e47a1b0469dd23d79c57d905ec72 Mon Sep 17 00:00:00 2001 From: Fabian Blank Date: Mon, 28 Aug 2023 17:00:18 +0200 Subject: [PATCH 2/2] remove log --- frontend/src/js/tooltip/Tooltip.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/js/tooltip/Tooltip.tsx b/frontend/src/js/tooltip/Tooltip.tsx index bfbf5247a4..2e8c0fe511 100644 --- a/frontend/src/js/tooltip/Tooltip.tsx +++ b/frontend/src/js/tooltip/Tooltip.tsx @@ -189,7 +189,6 @@ const Tooltip = () => { ); const highlightRegex = useMemo(() => { - console.log("words", words); return words.length > 0 ? new RegExp(words.filter((word) => word.length > 0).join("|"), "gi") : null;