diff --git a/source/components/SearchBar.js b/source/components/SearchBar.js
index c45c66d40..430a252f8 100644
--- a/source/components/SearchBar.js
+++ b/source/components/SearchBar.js
@@ -53,13 +53,15 @@ let SearchBar = ({
color: var(--textColour);
}
`}
- onClick={() => setSelectedOption(option)}>
+ onClick={() => setSelectedOption(option)}
+ >
+ }}
+ >
+ to={sitePaths.documentation.index + '/' + encodeRuleName(dottedName)}
+ >
{
+ worker.postMessage({
+ options
+ })
- if (!options) return null
+ worker.onmessage = ({ data: results }) => setSearchResults(results)
+ }, [])
return (
<>
@@ -33,17 +40,12 @@ function SelectComponent({ setFormValue, submit, options }) {
`}
placeholder="Saisissez votre domaine d'activité"
onChange={e => {
- if (e.target.value.length < 2) {
+ let input = e.target.value
+ if (input.length < 2) {
setSearchResults(undefined)
return
}
- setSearchResults(
- options.filter(option =>
- option['Nature du risque']
- .toLocaleLowerCase()
- .includes(e.target.value.toLocaleLowerCase())
- )
- )
+ worker.postMessage({ input })
}}
/>
{searchResults && searchResults.length === 0 && (
@@ -149,5 +151,6 @@ export default FormDecorator('select')(function Select(props) {
)
}, [])
+ if (!options) return null
return
})
diff --git a/source/components/conversation/select/SelectTauxRisque.worker.js b/source/components/conversation/select/SelectTauxRisque.worker.js
new file mode 100644
index 000000000..976b53216
--- /dev/null
+++ b/source/components/conversation/select/SelectTauxRisque.worker.js
@@ -0,0 +1,15 @@
+import Fuse from 'fuse.js'
+
+let fuse = null
+onmessage = function(event) {
+ if (event.data.options)
+ fuse = new Fuse(event.data.options, {
+ keys: ['Nature du risque', 'Catégorie'],
+ shouldSort: true
+ })
+
+ if (event.data.input) {
+ let results = fuse.search(event.data.input)
+ postMessage(results)
+ }
+}