Skip to content

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Aug 7, 2025

An isolated index does not get requested when changes happen in the parent and also does not inherit its search parameters.

If you want an isolated index to search, you need to cause a search (eg by refining a child widget)

isolated indices:

  • do not automatically search when mounted
  • do not show up in ui state
  • do not interact with onStateChange
  • do not get requested in server-side rendering
  • do not cause searches in parent indices

This option is EXPERIMENTAL, and implementation details may change in the future. Things that could change are:

  • which widgets get rendered when a change happens
  • whether the index searches automatically
  • whether the index is included in the URL / UiState
  • whether the index is include in server-side rendering

Usage:

search.addWidgets([
  index({ EXPERIMENTAL_isolated: true, indexName: 'alone' })
]);

search.addWidgets([
  index({ EXPERIMENTAL_isolated: false }).addWidgets([
    index({ indexName: 'isolated' })
  ]),
]);

FX-3448

supersedes the following POCs:

An isolated index does not get requested when changes happen in the parent and also does not inherit its search parameters.

If you want an isolated index to search, you need to cause a search (eg by refining a child widget)

isolated indices:
- do not automatically search when mounted
- do not show up in ui state
- do not interact with  onStateChange
- do not get requested in server-side rendering
- do not cause searches in parent indices

This option is EXPERIMENTAL, and implementation details may change in the future.
Things that could change are:
- which widgets get rendered when a change happens
- whether the index searches automatically
- whether the index is included in the URL / UiState
- whether the index is include in server-side rendering

Usage:

```js
search.addWidgets([
  index({ isolated: true, indexName: 'alone' })
]);

search.addWidgets([
  index({ isolated: false }).addWidgets([
    index({ indexName: 'isolated' })
  ]),
]);
```

[FX-3448]

supersedes the following POCs:
- closes #6880
- closes #5939
@Haroenv Haroenv requested a review from Copilot August 7, 2025 16:32
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces an experimental "isolated" option for the index widget that allows indices to operate independently from their parent context. Isolated indices do not automatically search when mounted, are excluded from UI state, don't interact with onStateChange, and don't get requested in server-side rendering.

Key changes:

  • Modified IndexWidgetParams type to support optional isolated configuration with union types
  • Implemented isolation logic affecting search behavior, parent relationships, and UI state inclusion
  • Added comprehensive test coverage for isolated index functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/instantsearch.js/src/widgets/index/index.ts Core implementation of isolated index functionality including type definitions, search behavior modifications, and parent relationship handling
packages/instantsearch.js/src/widgets/index/tests/index-test.ts Comprehensive test suite covering isolated index behavior, UI state exclusion, and search triggering scenarios
packages/instantsearch.js/src/lib/InstantSearch.ts Updated composition client validation to exclude isolated indices from the restriction

Copy link

codesandbox-ci bot commented Aug 7, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 30c6736:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

@Haroenv Haroenv marked this pull request as ready for review August 8, 2025 08:03
@Haroenv Haroenv requested review from a team, dhayab and shaejaz and removed request for a team August 8, 2025 08:03
Copy link
Member

@dhayab dhayab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome addition 👏

@Haroenv Haroenv enabled auto-merge (squash) August 12, 2025 15:38
@Haroenv Haroenv merged commit fcee78a into master Aug 12, 2025
14 checks passed
@Haroenv Haroenv deleted the feat/isolated-index branch August 12, 2025 15:46
@dhayab dhayab restored the feat/isolated-index branch August 12, 2025 16:58
@dhayab dhayab deleted the feat/isolated-index branch August 12, 2025 16:59
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.

3 participants