4

I have a problem, when you make a search a select an item from the refinementList and without removing the selected item search for something else the selected item disappears from list due to the limit it have, how can i set it to always show the selected item of the refinementList?

with the refinementList item selected

search for something else but the item is gone

  • what code have you tried? – n1c9 Mar 30 '16 at 21:19
  • This is currently not doable but a good idea, can you please open a new github issue here: https://github.com/algolia/instantsearch.js/issues – vvo Mar 30 '16 at 21:30

2 Answers2

1

This is currently not doable without creating a custom widget.

The currentRefinedValues widget partly solves this issue though, since it lists all checked refinements.

I've opened an issue on instantsearch.js's repo about this, I think this should be better suited than StackOverflow for this request.

Jerska
  • 11,722
  • 4
  • 35
  • 54
1

Actually, internally the already refined facets are present in the list but they are not relevant enough to be on display in the list. This can be solved by tweaking the sortBy argument of the refinementList. In the example you are using, you can fix it like that:

search.addWidget(
  instantsearch.widgets.refinementList({
    container: '#materials',
    attributeName: 'materials',
    operator: 'or',
    limit: 10,
    sortBy: ['isRefined', 'count:desc', 'name:asc'],
    templates: {
      item: facetTemplateCheckbox,
      header: '<div class="facet-title">Materials</div class="facet-title">'
    }
  })
);

Note the use of 'isRefined' as the first predicate of the sortBy. This makes sure that already refined values will always be visible to the users.

Here is a gif of the new behaviour:

Fixed behavior

bobylito
  • 3,172
  • 22
  • 27