defaultRefinement not showing filtered results

Hey,

I’m trying to get a preset filter of choice to work, I applied defaultRefinement={[‘BMW’]} to my RefinementList, which is properly selecting the filter in the filters page, it’s however not actually applying the filter to the results.

If I select any other filter, it’ll work properly, and I can even de-select then re-select BMW and it’ll apply it properly as well. Still, the initial results are not filtered.

Am I missing something? Should I be applying something somewhere else? I’ve tried searching for similar issues but haven’t come up with anything.

The desired end result is to allow for users to use the quick search that is currently implemented, but also allow them to apply a filter, in this case brand, which can still be deselected in the filters tab if they want to change them.

I tried to do this a while back before scrapping it, I forgot what I used at the time, but the issue was that the filter was “permanently stuck” and couldn’t be deselected.

I’m using react-native.

Any pointers in the right correction would be very appreciated.

Thank you in advance!

Best Regards

Hi @Zango, that’s quite strange indeed! In order to help further, would you be able to reproduce the behavior in a Codesandbox and with your appID / search API key? That’ll allow us to investigate what requests are being sent and hopefully uncover why. This React InstantSearch template should be a good starting point: https://codesandbox.io/s/github/algolia/create-instantsearch-app/tree/templates/react-instantsearch

Please add just the minimum amount of code necessary to reproduce the issue. Thanks in advance!

Hey @maria.schreiber

Thanks for the quick reply.

I figured out the issue, I had to apply defaultRefinement in the VirtualRefinementList as well:

<VirtualRefinementList attribute=“data.brand” defaultRefinement={[‘BMW’]}/>

This got it working!

Thanks again,

Best Regards

Awesome, thanks for posting the solution and letting us know!