I've noted that when pulling additional elements from state using WithSearch will result in autocomplete only processing one character at a time. In the example code below I'm extracting searchTerm to pass onto child components such as ExportButton:
<SearchProvider config={config}>
<WithSearch mapContextToProps={({ wasSearched, searchTerm }) => ({ wasSearched, searchTerm})}>
{({ wasSearched, searchTerm}) => {
return (
<div className="App">
<ErrorBoundary>
<Layout
header={
<SearchBox autocompleteSuggestions={true}
inputView={({ getAutocomplete, getInputProps, getButtonProps}) => (
<>
/*******
*** PASS THE SEARCH TERM TO A CUSTOM COMPONENT
********/
<ExportButton lastSearch={searchTerm}></ExportButton>
/*******
***
********/
<input
{...getButtonProps({
"data-custom-attr": "some value"
})}
style={{
marginRight: "10px"
}}
/>
<div className="sui-search-box__wrapper">
<input
{...getInputProps({
placeholder: "I am a custom placeholder"
})}
/>
{getAutocomplete()}
</div>
</>
)}
/>
}
sideContent={
<div>
{wasSearched && (
<Sorting
label={"Sort by"}
sortOptions={buildSortOptionsFromConfig()}
/>
)}
{getFacetFields().map(field => (
<Facet key={field} field={field} label={field} />
))}
</div>
}
bodyContent={
<Results
titleField={getConfig().titleField}
urlField={getConfig().urlField}
thumbnailField={getConfig().thumbnailField}
shouldTrackClickThrough={true}
resultView={VaersaView}
/>
}
bodyHeader={
<React.Fragment>
{wasSearched && <PagingInfo />}
{wasSearched && <ResultsPerPage />}
</React.Fragment>
}
bodyFooter={<Paging />}
/>
</ErrorBoundary>
</div>
);
}}
</WithSearch>
</SearchProvider>
The autocomplete input loses focus after each letter is typed..
My goal is provide the searchTerm and filters objects to the export button. Thanks in advance.