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.

Feature Request / Use case clarification

See original GitHub issue

I want to be able to render a message in the dropdown when there are no results. I tried using the renderSuggestionsContainer prop, however it seems that the dropdown is closed upon no results. There’s probably a way to do this with the existing props, but theres so many ways to do this.


Potential solutions:

A) Could add an explicit prop closeOnNoResults which defaults to true, but when set to false will not close the dropdown upon no results. B) Some sort of weird css class fix on my side (seems really messy) C) Make the component such that if there are no results it’s still invisible, unless you are defined renderSuggestionsContainer to render other items. (tricky as container padding etc would mess things up) D) Making the state of the popover controllable by the end user (me) and having simple steps to do this.

Seeming solutions which aren’t:

  • Using alwaysRenderSuggestions - as I still want to hide it onBlur, and preserve the other functionality

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
james-ffcommented, Dec 12, 2017

I managed to achieve this effect via a workaround until the feature is implemented. I used a boolean in state to track when suggestions should be shown and should not. When text is entered and results should not be shown (ie. no results message should be shown), set suggestions to anything so that it displays the dropdown and in the function “renderSuggestionsContainer” don’t display the children contents (which will contain the suggestions that you entered just to make the dropdown show). I also made “renderSuggestionsContainer” a method of the component class so that it has access to “this” and consequently “this.state”. Code below to illustrate:

renderSuggestionsContainer = ({ containerProps, children, query }) => {
    const resultsHeader = (
      <div style={{ margin: "9px 20px", fontSize: "14px", color: "#777" }}>
        Select a Single Card to Compare
      </div>
    );
    const noResultsHeader = (
      <div style={{ margin: "9px 20px", fontSize: "14px", color: "#777" }}>
        No card names contain "{query}"
      </div>
    );
    return (
      <div {...containerProps}>
        {!this.state.noSuggestions && resultsHeader}
        {!this.state.noSuggestions && children}
        {this.state.noSuggestions && noResultsHeader}
      </div>
    );
  }

Example of when text is entered but it gives no suggestions ([“INVALID”] can be replaced with whatever as its contents are not going to be displayed, but suggestions must be non-empty as this is what will cause the dropdown to display):

this.setState({
    suggestions: json.data.length === 0 ? ["INVALID"] : json.data,
    noSuggestions: json.data.length === 0
});
1reaction
davidfurlongcommented, Dec 13, 2017

Thats a creative solution, thanks for sharing @james-ff

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request response email templates - LiveAgent
Feature requests are messages that customers send to inquire about a feature that is not included in your product or service. Receiving feature...
Read more >
10 Tips for Responding Graciously to Customer Feature ...
10 Tips for Responding Graciously to Customer Feature Requests · 1. Be open and honest · 2. Be grateful for their effort ·...
Read more >
Feature Request Template: How to Manage Suggestions at ...
Clarify the request with its contributor​​ Ask questions to make sure you understand their pain points. If they're asking for a specific feature, ......
Read more >
The right way to respond to feature requests - Inside Intercom
Here's our best practice guide on responding to feature requests in a human ... In these cases, use the request as a jumping...
Read more >
Managing feature requests: A comprehensive guide - UserVoice
Feature requests are invaluable opportunities to discover ways to improve your product and better serve your users' ever-evolving needs. A smooth feature ...
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