Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(connectSortBy): do not throw with wrong indexes #3824

Merged
merged 5 commits into from May 28, 2019

Conversation

francoischalifour
Copy link
Member

This PR closes #3397.

The sortBy connector used to throw an error when the current index wasn't listed in the items of the widget.

This broke some users' apps when using routing. If users type a URL with a wrong index name for the sortBy widget, it will throw straight away and break the InstantSearch lifecycle.

This PR removes the error thrown and rathers warns only in development. The initial index (from the helper) is used if that happens.

I slightly changed the implementation because we were relying on the InstantSearch instance index (instantSearch.indexName) and now use the helper index (helper.getIndex()). This shouldn't break anything and is more consistent within the connector.

The deleted tests in the widget are now covered in the connector.

@francoischalifour francoischalifour requested review from samouss and a team May 28, 2019 14:37
@ghost ghost requested review from tkrugg and removed request for a team May 28, 2019 14:37
@francoischalifour francoischalifour requested review from yannickcr and removed request for tkrugg May 28, 2019 14:43
@algobot
Copy link
Contributor

algobot commented May 28, 2019

Deploy preview for instantsearchjs ready!

Built with commit b45d0c2

https://deploy-preview-3824--instantsearchjs.netlify.com

@francoischalifour francoischalifour merged commit 2a84ee2 into develop May 28, 2019
@francoischalifour francoischalifour deleted the fix/sortBy-missing-index branch May 28, 2019 18:22
eunjae-lee pushed a commit that referenced this pull request Jul 1, 2019
## [3.5.4](v3.5.3...v3.5.4) (2019-07-01)

### Bug Fixes

* **connectSortBy:** do not throw with wrong indexes ([#3824](#3824)) ([2a84ee2](2a84ee2))
* **deps:** update dependency instantsearch.js to v3.5.3 ([#3877](#3877)) ([463f3bb](463f3bb))
* **escape:** make sure that __escaped does not get removed ([#3830](#3830)) ([fbafd22](fbafd22))
* **getRefinements:** check for facet before accessing its data ([#3842](#3842)) ([aadc769](aadc769))
* **panel:** return value from dispose ([#3895](#3895)) ([bceb78f](bceb78f))
* **voiceSearch:** remove event listeners on stop ([#3845](#3845)) ([688e36a](688e36a))
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.

[connectSortBy] avoid to throw an error when the index does not exist
4 participants