Skip to content

Conversation

@indykoning
Copy link
Member

See: https://www.algolia.com/doc/guides/building-search-ui/widgets/show-and-hide-widgets/vue#enable-preservesharedstateonunmount

This feature will be default in a future release of Instantsearch.
Enabling this will prevent bugs by not removing search filters when their respective component gets removed. As long as an element still uses it.

What could happen before this addition is you setting a default value in an ais-configure element, and removing the element when a different value is passed:

<ais-state-results v-slot="{ state: { query } }">
    <div>
        <ais-configure
            v-if="!query"
            :query="query || '__NO_QUERY__'"
        />
    </div>
</ais-state-results>

<ais-search-box>
...
</ais-search-box>

If preservesharedstateonunmount is false v-if="!query" would cause ais-configure to unmount.
Forcing query to be set to null, thus re-mounting the ais-configure component and setting query again.
If preservesharedstateonunmount is true, instantsearch detects ais-search-box updates query as well. And does noet clear the querys value

@indykoning indykoning requested a review from royduin as a code owner October 31, 2025 12:45
Jade-GG
Jade-GG previously approved these changes Nov 3, 2025
@royduin
Copy link
Member

royduin commented Nov 4, 2025

Should we extract this somewhere? I see this (and other attributes) multiple times in different files

@royduin
Copy link
Member

royduin commented Nov 18, 2025

Conflicts 😇 and we need this for 4.x and 5.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants