Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

wip: introduce parentIndexId #3690

Closed
wants to merge 3 commits into from
Closed

wip: introduce parentIndexId #3690

wants to merge 3 commits into from

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Nov 28, 2022

This would be useful for cases like https://github.com/algolia/react-instantsearch/discussions/3689#discussioncomment-4251317 where the cascade is working against your implementation.

The reason this is WIP is because I think without having a bare root (without the workaround in App.tsx) you still need to prevent searches on the main index and that's still fairly "ugly". If InstantSearch would have an option to prevent mainIndex from searching (so actually having an array of root indices instead of a single one) it would be much more useful

This would be useful for cases like https://github.com/algolia/react-instantsearch/discussions/3689#discussioncomment-4251317 where the cascade is working against your implementation.

The reason this is WIP is because I think without having a bare root (without the workaround in App.tsx) you still need to prevent searches on the main index and that's still fairly "ugly". If InstantSearch would have an option to prevent mainIndex from searching (so actually having an array of root indices instead of a single one) it would be much more useful
@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 28, 2022

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 bac47f7:

Sandbox Source
react-instantsearch-app Configuration
hooks-example Configuration

@netlify
Copy link

netlify bot commented Nov 28, 2022

Deploy Preview for react-instantsearch ready!

Name Link
🔨 Latest commit bac47f7
🔍 Latest deploy log https://app.netlify.com/sites/react-instantsearch/deploys/6384d2e6f2c6e8000916c909
😎 Deploy Preview https://deploy-preview-3690--react-instantsearch.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

: item.label;
<Index
indexName="autocomplete_demo_products_query_suggestions"
parentIndexId="instant_search"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

more ideally parentIndexId={null} would behave as another mainIndex, but not sure how that can be done. It could of course be implemented later as well

Copy link
Member

Choose a reason for hiding this comment

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

I think we can resolve null to useInstantSearchContext().indexName.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, null could be mainIndex, but it wouldn't really solve the issue here (needing to have a manual index at the root with different indexId), as that mainIndex would probably have widgets as well, negating the point of parentId a bit (I could almost only imagine use cases where you want no parameters to be inherited)

Copy link
Member

Choose a reason for hiding this comment

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

I wonder how easier the mental model would be if we require an <Index> within <InstantSearch>.

Because we can't really portal an <Index> to an empty Helper in the current state. The root is shared among all <Index>.

(I see this problem a bit like Element and Fragment.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that's what I had in mind as well, possibly that could be detected when the InstantSearch instance doesn't receive an indexName prop, you render Index manually, and thus will be able to have adjacent root indices

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants