Closed jonathanjr3 closed 2 months ago
@VladislavFitz adding another observation here, this is happening with a custom scrollview and SwiftUI's native List
too. Please let me know if there are any updates and if you need more details on this, thank you.
Reached out to algolia support team and the solution they provided has fixed this issue, closing this issue henceforth.
Describe the bug 🐛 The
hits
property inHitsObservableController
which comes withInstantSearchSwiftUI
library is not updating results properly, results from previous fetch are also included in the list. I've observed that this only happens when user scrolls past the offset limit set in theHitsInteractor
infinite scrolling parameter.For example: Let's assume the total number of hits without any filter applied is 25. Algolia SDK fetches 20 hits by default on first load of the page and I've also set
infiniteScrolling
to on with 10 as offset like this:Scrolling past the first 10 hits loads the remaining 5 and updates the
hits
property inHitsObservableController
as expected. The total result count of thehits
property is 25 now.If I apply a filter with a facet which has just 1 value for example, the relevant result is at the top of the
hits
list but the other 5 values which were fetched previously are also included in the list. So the list is showing 6 results instead of 1.This does not happen if we don't scroll past the offset limit (i.e 10), the
hits
list contains only the expected result (1 in this case) if we don't scroll past the limit.To simplify this:
(
infiniteScrolling
offset set as 5)hits
list (assuming it loads 5 by default) : A, B, C, D, EI'm applying filters using
toggle(_ facet: Facet, for attribute: Attribute)
function inDynamicFacetListObservableController
and disjunctive groups in FilterState usingfilterState[or: attribute].addAll()
To Reproduce 🔍 Steps to reproduce the behavior:
HitsSearcher
,HitsInteractor
andHitsObservableController
objects usingHitsConnector
infiniteScrolling
to on with offset as 10 inHitsInteractor
objectHitsList
view provided byInstantSearchSwiftUI
hits
property will have the relevant result as the first element, including the ones fetched previously.Expected behavior 💭
hits
list inHitsObservableController
should only have the relevant result(s)Screenshots 🖥 Initial list without any filters applied, without scrolling, includes all results:
Applying a filter with a facet which has 1 value (Beachtennis):
Works as expected, showing 1 result:
Remove that filter, scroll past 10 items and apply the same filter:
Here you could see the relevant result is at the top but the results which were fetched before due to scrolling below are also included
Screen recording:
https://github.com/algolia/instantsearch-ios/assets/123464885/1471d08e-f27d-4fa2-af0c-0b9a31d0628a
Side note: We're using
StatsTextObservableController
to show the number of results in the segmented picker below the search barEnvironment:
Additional context Please let me know if you need more details.