There should be some way to initiate an initial, empty query when the UI loads.
See original GitHub issueHere is an example:
When navigating to the sandbox example at http://localhost:3000, currently, you will see no results. When navigating to the sandbox example at http://localhosts:3000?q=park, you WILL see results, because a ‘q’ parameter is being passed and a query is performed.
There should be a way to tell Search UI to also trigger a search and show results in the first example, where no ‘q’ parameter is passed.
A proposal might be to have something like the following, using a “shouldSearchOnInitialLoad” boolean flag in configuration.
<SearchProvider
config={{
apiConnector: connector,
shouldSearchOnInitialLoad: true
}}
>
...
</SearchProvider>
As Constance points out in a comment below, the corresponding change would need to be made here: https://github.com/elastic/search-ui/blob/master/packages/search-ui/src/SearchDriver.js#L160.
I believe the logic may be as simple as adding an additional condition to check if shouldSearchOnInitialLoad
is true when deciding whether or not to perform a search.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (13 by maintainers)
Sorry for taking a while on this. I think the line no. mentioned might not be accurate? I think the line no is
175
. Please correct me if I’m wrong.The conditional checks if a
valid searchTerm
is present or there’s at least 1 filter. We’ll be replacing the check for avalid searchTerm
with the flagshouldSearchOnInitialLoad
, right?Hi @delvedor 👋. You had mentioned this earlier, just wanted to point the issue out to you if you’d like to follow it.