Skip to content

Commit

Permalink
Merge pull request #3160 from ingef/fix/highlighting-with-space-at-end
Browse files Browse the repository at this point in the history
Fix Bug where highlighting Breaks with search term ending with a space
  • Loading branch information
fabian-bizfactory authored Aug 29, 2023
2 parents a4b71b2 + 3b3ec99 commit fbb9d36
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frontend/src/js/tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ const Tooltip = () => {
(state) => state.tooltip.toggleAdditionalInfos,
);

const highlightRegex = useMemo(
() => (words.length > 0 ? new RegExp(words.join("|"), "gi") : null),
[words],
);
const highlightRegex = useMemo(() => {
return words.length > 0
? new RegExp(words.filter((word) => word.length > 0).join("|"), "gi")
: null;
}, [words]);

const dispatch = useDispatch();
const onToggleAdditionalInfos = () => dispatch(toggleInfos());
Expand Down

0 comments on commit fbb9d36

Please sign in to comment.