Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantsearch.js refinementList widget with searchForFacetValues: true leads to template/rendering error when there are no results #2087

Closed
sepehrfakour opened this issue Mar 31, 2017 · 0 comments

Comments

@sepehrfakour
Copy link

sepehrfakour commented Mar 31, 2017

When adding an instantsearch.js refinementList widget, a user can choose to define a template string/function to render facets. In the case where a user wants to allow searchable facets, whether or not a refinementList template is defined, the widget does a great job of rendering sensible markup when there are results...

However, when searching the refinement list for facet values AND there are NO relevant results returned by the API, an error is thrown in the browser:

Template must be 'string' or 'function', was 'undefined' (key: noResults)

The apparent solution here is to simply add the noResults property to the templates object that is passed to the refinementList widget declaration. However, I could not find any explanation of this in any guides...

I see that it is mentioned here but only in the params list.

There is little info in any guide I found concerning the topic of how to properly implement searchableAttributes, attributesForFaceting, or search-for-facet-values templating
( i.e here, here, or here).

I think it may be worthwhile to explicitly state somewhere in the instantsearch/templates guide that this noResults prop should be specified when building a searchable facets list.

Vincent suggested that this behavior is actually a bug:

"...by default if you do not provide the template for no results in the refinementList it should degrade nicely. If that's not the case then it's a miss"

I agree.

Here is a JS Fiddle I just wrote to demonstrate this issue. See error in browser dev console when searching with a query string that doesn't return results in the "Publisher" refinement list (e.g. a query like awdawdawd)

https://jsfiddle.net/aw30jpud/

@bobylito bobylito assigned bobylito and iam4x and unassigned bobylito May 22, 2017
@bobylito bobylito added this to the 2.0 milestone Jun 13, 2017
@bobylito bobylito removed this from the 2.0 milestone Jul 1, 2017
@bobylito bobylito assigned bobylito and unassigned iam4x Sep 5, 2017
bobylito pushed a commit that referenced this issue Sep 5, 2017
When there was no results and the template is not provided, is.js would
trigger an error.

Fix #2087
bobylito added a commit that referenced this issue Sep 5, 2017
When there was no results and the template is not provided, is.js would
trigger an error.

Fix #2087
bobylito pushed a commit that referenced this issue Sep 5, 2017
<a name=2.1.3></a>
## [2.1.3](v2.1.2...v2.1.3) (2017-09-05)

### Bug Fixes

* **Pagination:** add  to <Pagination /> ([#2296](#2296)) ([545f076](545f076))
* **sffv:** no error when not providing noResults and no results ([#2310](#2310)) ([cc02b71](cc02b71)), closes [#2087](#2087)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants