diff --git a/components/operators-detail/documentation/documents-by-operator.js b/components/operators-detail/documentation/documents-by-operator.js index c4490a05..28faaad2 100644 --- a/components/operators-detail/documentation/documents-by-operator.js +++ b/components/operators-detail/documentation/documents-by-operator.js @@ -45,13 +45,13 @@ function DocumentsByOperator({ groupedByCategory, searchText, user, id, intl, .. const fuse = new Fuse(documents, { keys: ['title'], threshold: 0.4, - minMatchCharLength: 2, + minMatchCharLength: 1, ignoreLocation: true, findAllMatches: true }); const exactSearchResults = searchText.length > 2 ? documents.filter(exactSearch) : []; - const fuseSearchResults = fuse.search(searchText); + const fuseSearchResults = fuse.search(searchText).map(r => r.item); return uniq([...exactSearchResults, ...fuseSearchResults]); } diff --git a/components/operators/table-expanded-row.js b/components/operators/table-expanded-row.js index 9be35458..f334ba6f 100644 --- a/components/operators/table-expanded-row.js +++ b/components/operators/table-expanded-row.js @@ -34,7 +34,7 @@ const TableExpandedRow = ({ operator, fmuSearch, intl }) => { distance: 100, threshold: 0.15 }); - fmus = fuse.search(fmuSearch); + fmus = fuse.search(fmuSearch).map(r => r.item); } return ( diff --git a/components/ui/search.js b/components/ui/search.js index 812a1341..0a1abbc8 100644 --- a/components/ui/search.js +++ b/components/ui/search.js @@ -171,7 +171,7 @@ class Search extends React.Component { this.setState({ index: 0, value: searchText, - results: result.slice(0, 8), + results: result.map(r => r.item).slice(0, 8), active: searchText !== '' }); } diff --git a/package.json b/package.json index a73a5f43..c83f9f9d 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "eventemitter3": "^5.0.1", "express": "^4.19.2", "foundation-sites": "^6.8.1", - "fuse.js": "^3.0.5", + "fuse.js": "^7.0.0", "globalthis": "^1.0.4", "html-react-parser": "^5.1.10", "jsona": "^1.12.1", diff --git a/selectors/operators-ranking/index.js b/selectors/operators-ranking/index.js index 3fab1c8d..260befdc 100644 --- a/selectors/operators-ranking/index.js +++ b/selectors/operators-ranking/index.js @@ -311,7 +311,7 @@ export const getTable = createSelector( if (activeOperatorSearch) { const fuse = new Fuse(operatorsTable || _data, SEARCH_OPTIONS); - operatorsTable = fuse.search(activeOperatorSearch); + operatorsTable = fuse.search(activeOperatorSearch).map(r => r.item); } if (activeFMUSearch) { @@ -321,7 +321,7 @@ export const getTable = createSelector( distance: 100, threshold: 0.15 }); - operatorsTable = fuse.search(activeFMUSearch); + operatorsTable = fuse.search(activeFMUSearch).map(r => r.item); } operatorsTable = (operatorsTable || _data).map(o => ({ diff --git a/yarn.lock b/yarn.lock index 689f5418..bccc4cfc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2626,10 +2626,10 @@ functions-have-names@^1.2.3: resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== -fuse.js@^3.0.5: - version "3.6.1" - resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-3.6.1.tgz#7de85fdd6e1b3377c23ce010892656385fd9b10c" - integrity sha512-hT9yh/tiinkmirKrlv4KWOjztdoZo1mx9Qh4KvWqC7isoXwdUY3PNWUxceF4/qO9R6riA2C29jdTOeQOIROjgw== +fuse.js@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-7.0.0.tgz#6573c9fcd4c8268e403b4fc7d7131ffcf99a9eb2" + integrity sha512-14F4hBIxqKvD4Zz/XjDc3y94mNZN6pRv3U13Udo0lNLCWRBUsrMv2xwcF/y/Z5sV6+FQW+/ow68cHpm4sunt8Q== geojson-vt@^3.2.1: version "3.2.1"