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

fix(MultiIndex): ensure getResults return only hits matching index in the context #136

Merged
merged 4 commits into from
Jun 26, 2017

Conversation

mthuret
Copy link
Contributor

@mthuret mthuret commented Jun 21, 2017

No description provided.

@algobot
Copy link
Contributor

algobot commented Jun 21, 2017

Deploy preview ready!

Built with commit 86fab70

https://deploy-preview-136--react-instantsearch.netlify.com

@mthuret mthuret requested a review from vvo June 22, 2017 08:07
@@ -41,7 +42,7 @@ describe('connectInfiniteHits', () => {
const hits2 = [{}, {}, {}, {}, {}, {}];
const hits3 = [{}, {}, {}, {}, {}, {}, {}, {}];
const res1 = getProvidedProps(null, null, {
results: { hits, page: 0, hitsPerPage: 6, nbPages: 10 },
results: { hits, page: 0, hitsPerPage: 6, nbPages: 10, index: 'index' },
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use "indexName" like other parts of the lib? I would say any moment we speak about an index name we should use the "indexName" token as we do in every JS lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

index is the name used on the SearchResults object from the helper.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it bubbles up to the React InstantSearch user API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're using the createConnector API yes, because you access searchResults otherwise it shouldn't.

@vvo
Copy link
Contributor

vvo commented Jun 23, 2017

Do you have a small example usage of when this happened?

On a side note, this is not only a fix but also a new feature where the index name is always passed down to the results (multi index or not) right?

@mthuret
Copy link
Contributor Author

mthuret commented Jun 23, 2017

@vvo Not sure to get what you mean but this bug is happening when switching from one indices to multiple indices. For example we saw it on an example showcasing "tabs". You have one tab that is all, and then one tab per index.

There is actually a better way to handle this (by namespacing every index, even when only one), but it would imply a breaking change. Initially we were using it, you can see this PR when I revert the breaking change. 44f7de0

Copy link
Contributor

@vvo vvo left a comment

Choose a reason for hiding this comment

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

LGTM, that .index prop was already here when using createConnector

@mthuret mthuret merged commit 124ffe6 into master Jun 26, 2017
@mthuret mthuret deleted the fix/ensure-getresults-return-right-hits branch June 26, 2017 08:13
mthuret pushed a commit that referenced this pull request Jun 26, 2017
<a name="4.0.5"></a>
## [4.0.5](v4.0.4...v4.0.5) (2017-06-26)

### Bug Fixes

* **MultiIndex:** ensure getResults return only hits matching index in the context (#136) ([124ffe6](124ffe6))
* **MultiIndex:** handle if namespace isn't in search state (#139) ([1aab324](1aab324))
* **storybook:** process CSS through autoprefixer (#138) ([62cf512](62cf512))
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.

3 participants