{"action":"created","issue":{"url":"https://api.github.com/repos/algolia/react-instantsearch/issues/2570","repository_url":"https://api.github.com/repos/algolia/react-instantsearch","labels_url":"https://api.github.com/repos/algolia/react-instantsearch/issues/2570/labels{/name}","comments_url":"https://api.github.com/repos/algolia/react-instantsearch/issues/2570/comments","events_url":"https://api.github.com/repos/algolia/react-instantsearch/issues/2570/events","html_url":"https://github.com/algolia/react-instantsearch/pull/2570","id":458678862,"node_id":"MDExOlB1bGxSZXF1ZXN0MjkwMjMyMDcy","number":2570,"title":" fix(createInstantSearchManager): fix multi-index search ","user":{"login":"yannickcr","id":13209,"node_id":"MDQ6VXNlcjEzMjA5","avatar_url":"https://avatars2.githubusercontent.com/u/13209?v=4","gravatar_id":"","url":"https://api.github.com/users/yannickcr","html_url":"https://github.com/yannickcr","followers_url":"https://api.github.com/users/yannickcr/followers","following_url":"https://api.github.com/users/yannickcr/following{/other_user}","gists_url":"https://api.github.com/users/yannickcr/gists{/gist_id}","starred_url":"https://api.github.com/users/yannickcr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yannickcr/subscriptions","organizations_url":"https://api.github.com/users/yannickcr/orgs","repos_url":"https://api.github.com/users/yannickcr/repos","events_url":"https://api.github.com/users/yannickcr/events{/privacy}","received_events_url":"https://api.github.com/users/yannickcr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-06-20T14:04:48Z","updated_at":"2019-06-20T14:50:09Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/algolia/react-instantsearch/pulls/2570","html_url":"https://github.com/algolia/react-instantsearch/pull/2570","diff_url":"https://github.com/algolia/react-instantsearch/pull/2570.diff","patch_url":"https://github.com/algolia/react-instantsearch/pull/2570.patch"},"body":"<!--\r\n  Thanks for submitting a pull request!\r\n  Please provide enough information so that others can review your pull request.\r\n-->\r\n\r\n**Summary**\r\n\r\nThe multi-index support was broken since the migration to the new React context (https://github.com/algolia/react-instantsearch/pull/2178).\r\n\r\nThis issue is due to multiple small changes:\r\n\r\n* The context is now passed though the widget props but some functions in `createInstantSearchManager.js` were still trying to read it from `widget.context`.\r\n* The `indexId` prop is no longer required on the `Index` widget, so the `Index` widget detection was not working correctly anymore.\r\n* The widgets are now registered during the `componentDidMount` (before the change they were registered in the `constructor`), so the registration order is different. And since we're using a `reduce` on the widget list to calculate the `SearchParameters` the end result was different.\r\n\r\nThis PR makes the following fixes:\r\n\r\n* The functions that were relying on on `widget.context` were updated to use `widget.props` instead.\r\n* We now use `IndexName` in addition to `indexId` to detect the `Index` widgets (still avoided to use `instanceof` to keep the same logic).\r\n* Added a new step during the `mainParameters` and `derivedIndices` calculations to sort the `Index` widgets first so the following `reduce` result is correct.\r\n\r\n<!--\r\n  Explain the **motivation** for making this change.\r\n  What existing problem does the pull request solve?\r\n  Are there any linked issues?\r\n-->\r\n\r\n**Result**\r\n\r\nAll Storybook `<Index>` stories are now working.\r\nI'm not sure how to test this using unit tests (the existing tests are a bit odd as we register some \"dummy\" widgets and use them to calculate the `mainParameters` and `derivedParameters`).\r\n\r\nAny help to reproduce storybook cases as real tests would be very helpful here :wink: \r\n\r\n<!--\r\n  Demonstrate the code is solid.\r\n  Example: The exact commands you ran and their output,\r\n  screenshots / videos if the pull request changes UI.\r\n-->\r\n"},"comment":{"url":"https://api.github.com/repos/algolia/react-instantsearch/issues/comments/504056415","html_url":"https://github.com/algolia/react-instantsearch/pull/2570#issuecomment-504056415","issue_url":"https://api.github.com/repos/algolia/react-instantsearch/issues/2570","id":504056415,"node_id":"MDEyOklzc3VlQ29tbWVudDUwNDA1NjQxNQ==","user":{"login":"algobot","id":16079583,"node_id":"MDQ6VXNlcjE2MDc5NTgz","avatar_url":"https://avatars0.githubusercontent.com/u/16079583?v=4","gravatar_id":"","url":"https://api.github.com/users/algobot","html_url":"https://github.com/algobot","followers_url":"https://api.github.com/users/algobot/followers","following_url":"https://api.github.com/users/algobot/following{/other_user}","gists_url":"https://api.github.com/users/algobot/gists{/gist_id}","starred_url":"https://api.github.com/users/algobot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algobot/subscriptions","organizations_url":"https://api.github.com/users/algobot/orgs","repos_url":"https://api.github.com/users/algobot/repos","events_url":"https://api.github.com/users/algobot/events{/privacy}","received_events_url":"https://api.github.com/users/algobot/received_events","type":"User","site_admin":false},"created_at":"2019-06-20T14:50:09Z","updated_at":"2019-06-20T14:50:09Z","author_association":"CONTRIBUTOR","body":"Deploy preview for *react-instantsearch* ready!\n\nBuilt with commit b1ab79fa45fa62df4b409de576695d9e8ddde98a\n\nhttps://deploy-preview-2570--react-instantsearch.netlify.com"}}
{"actor":{"display_login":"algobot"}}