Skip to content

Commit

Permalink
Fix search regex bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DantSu committed May 3, 2024
1 parent cc78720 commit 120fdc5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/App/Components/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ function Table({
setDataFiltered(data)
return
}
const regSearch = new RegExp('.*(' + searchInput.current.value.split(' ').join(').*(') + ').*', 'gi')
const regSearch = '.*(' + searchInput.current.value.split(' ').join(').*(') + ').*'
setDataFiltered(
data.reduce(
(acc, d) => {
if (d.tableGroup !== undefined) {
const children = d.tableChildren.filter((d) => regSearch.test(d.cellTitle))
const children = d.tableChildren.filter((d) => new RegExp(regSearch, 'gi').test(d.cellTitle))
if (children.length) {
return [
...acc,
Expand All @@ -67,7 +67,7 @@ function Table({
]
}
} else {
if (regSearch.test(d.cellTitle)) {
if (new RegExp(regSearch, 'gi').test(d.cellTitle)) {
return [...acc, d]
}
}
Expand Down

0 comments on commit 120fdc5

Please sign in to comment.