atoms-studio / nuxt-swiftsearch

A tailor made implementation of algolia instantsearch for nuxt 3
MIT License
52 stars 5 forks source link

Issue with use state keys in filters #20

Open glennjacobs opened 5 days ago

glennjacobs commented 5 days ago

We’re building an online store with Nuxt and using this package for our category pages. Each category requires its own distinct instance of Algolia search.

To achieve this, we’ve utilised the :instance-key prop on the <ais-instant-search> component, which ensures each page gets its own separate instance.

However, the filter components, such as those created using useAisRefinementList, have a static key hardcoded currently (see this line). This causes the filters to behave incorrectly when switching between pages in our app.

I’ve tested a workaround by incorporating the instance ID into the state key, and it resolves the issue.

I plan to work on a PR to address this properly but would appreciate any feedback you have, especially if you have a preferred approach for implementing this fix.

Rigo-m commented 3 days ago

Hi glenn! Hope you are enjoying swiftsearch! I'll take a quick look at the pr, thanks!

Rigo-m commented 3 days ago

As a side note: why does each category require its own instant search instance? This can be quite heavy on user's memory. How many category pages do you have in your website?

glennjacobs commented 3 days ago

As a side note: why does each category require its own instant search instance? This can be quite heavy on user's memory. How many category pages do you have in your website?

It's because we're using keep-alive so the user can hit the back button a few times. Therefore it is limited.