question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There should be some way to initiate an initial, empty query when the UI loads.

See original GitHub issue

Here 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
Kacppiancommented, Jul 29, 2019

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 a valid searchTerm with the flag shouldSearchOnInitialLoad, right?

1reaction
JasonStoltzcommented, Jun 5, 2019

Hi @delvedor 👋. You had mentioned this earlier, just wanted to point the issue out to you if you’d like to follow it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature Request - Ability to prevent search on init · Issue #1111
The best way to go (if you're not displaying the empty searches at all) is to do the following: make a custom search...
Read more >
Algolia Instant Search - how to not do the initial search?
Here's an example taken from this Github issue. The search is not performed if the query is empty, as it will be on...
Read more >
UI best practices for loading, error, and empty states in React
In this article, we'll cover the best practices to use in client-side rendered React apps when handling loading, error, and empty state.
Read more >
Conditional display in React InstantSearch - Algolia
By default, React InstantSearch always shows you results, even when the query is empty. Depending on your use case and how you build...
Read more >
Subscriptions - Apollo GraphQL Docs
Unlike with a query, there is no expectation that the server will ... Import and initialize a GraphQLWsLink object in the same project...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found