Skip to content

Commit

Permalink
[@mantine/core] Highlight: Fix incorrect highlighted parts when one o…
Browse files Browse the repository at this point in the history
…f the array items includes substrings of other item (#5045)
  • Loading branch information
wgpsutherland authored Oct 19, 2023
1 parent 7968a64 commit 2f6a021
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function highlighter(value: string, _highlight: string | string[]) {
: highlight
.filter((part) => part.trim().length !== 0)
.map((part) => part.trim())
.sort((a, b) => b.length - a.length) // sorts by longest string first
.join('|');

const re = new RegExp(`(${matcher})`, 'gi');
Expand Down

0 comments on commit 2f6a021

Please sign in to comment.