algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

Applying filters in Configure also changes the filters refinement List #3065

Closed syedateeb1 closed 1 year ago

syedateeb1 commented 3 years ago

Hey i'm apply filters in Configure component and Search results are showing according to filters. But when i again open the filters list its also changes . I dont know why

<InstantSearch searchClient={searchClient} indexName={index} searchState = {searchState} onSearchStateChange = {onSearchStateChange}>
      <Configure
        index={index}
        query={query}
        filters={filters}
      />
      <Container onStartShouldSetResponder={() => setShowSort(false)}>
        <Filters setFilters={setFilters}  showFilters = {showFilters} setShowFilters = {setShowFilters}/>
        <InfiniteHits />
      </Container>
    </InstantSearch>
Haroenv commented 3 years ago

I don't understand what you mean? If this is related to your previous opened issue, this is because the facet count when you add it with filters will mean "all facets that can still be applied if this filters are applied". If you don't have arrays of facet values, that will be only the facets/values that you put in filters.

The correct way to make this interface is using disjunctive filters, which is done if you use a virtual refinement list, as said in the previous issue. I don't understand why that's not possible for you.

Thanks!

Haroenv commented 3 years ago

Very sorry, I confused you with someone else that had the exact same question that also used the default profile picture here: https://github.com/algolia/react-instantsearch/issues/3064

syedateeb1 commented 3 years ago

Its Okay. to be more clarify i did not create new InstantSearch component in my Filter Component class.

syedateeb1 commented 3 years ago

How can we pass multiple attributes to virtual refinement widget?

francoischalifour commented 3 years ago

Not sure what you want to do, but you can add as many virtual RefinementList components as necessary in your tree—each with an attribute.

syedateeb1 commented 3 years ago

I know that. Let me rephrase the issue i'm getting When i apply a filter from my filter modal then it applies to my search results. But When i reopen my filter modal, i am not able to see what filter i have previously selected. It was working fine before when i was using new InstantSearch component in my Fitler modal. I remove it so there will be only one InstantSearch used in my code. After that this issue arrived

syedateeb1 commented 3 years ago

I'm sorry i'm not good in explaining. But i really need the help :(

Haroenv commented 3 years ago

Can you make a sandbox with your code please @syedateeb1? We have a template available for that purpose here. Thanks!

syedateeb1 commented 3 years ago

https://codesandbox.io/s/lucid-river-uux9x?file=/App.js

Haroenv commented 3 years ago

You were very close with that implementation, but just needed to add onSearchStateChange & searchState to the root InstantSearch instance: https://codesandbox.io/s/gracious-voice-ebcoz

see also https://www.algolia.com/doc/guides/building-search-ui/going-further/native/react/?language=react#create-a-modal and https://github.com/algolia/react-instantsearch/issues/892

syedateeb1 commented 3 years ago

Is it possible without having InstantSearch in filters modal? As filter component is already inside InstantSearch. Then why we have to again declare it in filter component too?

markosrx commented 2 years ago

Is this still active or did anyone find a solution for this, I am facing the same problem. Thanks.

Haroenv commented 2 years ago

@markosrx could you open a new issue with reproduction please?

sarahdayan commented 1 year ago

Hey!

We're doing a round of clean up before migrating this repository to the new InstantSearch monorepo. This issue seems not to have generated much activity lately and to be mostly solved, so we're going to close it.