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

fix(panel): safely access state in mapStateToCanRefine #876

Merged
merged 19 commits into from
Oct 5, 2020

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Oct 1, 2020

Most of the widgets were assuming the shape of state is always "right", but since #871 it is also called with an empty object. This PR does the following things:

  • changes all widgets to work correctly with empty object
  • makes sure always a boolean is returned from mapStateToCanRefine to make tests easier
  • make tests of mapStateToCanRefine consistent, as well as adding a unit test to each of the methods using {} as state

closes #875
fixes #874

@Haroenv Haroenv marked this pull request as ready for review October 1, 2020 16:40
@@ -2,7 +2,7 @@

exports[`allows search bar classes override when it's searchable 1`] = `

<div class="ais-RefinementList ais-RefinementList--noRefinement">
<div class="ais-RefinementList">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is because the test used to be wrong (didn't pass canRefine in defaultState)

Copy link
Contributor

@eunjae-lee eunjae-lee left a comment

Choose a reason for hiding this comment

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

Looks good to me 🙌

Co-authored-by: Eunjae Lee <eunjae.lee@algolia.com>
@Haroenv Haroenv merged commit 435c7d3 into master Oct 5, 2020
@Haroenv Haroenv deleted the fix/panel-can-refine branch October 5, 2020 07:41
Haroenv added a commit to algolia/instantsearch that referenced this pull request Dec 28, 2022
…nstantsearch#876)

Most of the widgets were assuming the shape of state is always "right", but since algolia/vue-instantsearch#871 it is also called with an empty object. This PR does the following things:

- changes all widgets to work correctly with empty object
- makes sure always a boolean is returned from mapStateToCanRefine to make tests easier
- make tests of mapStateToCanRefine consistent, as well as adding a unit test to each of the methods using {} as state

closes algolia/vue-instantsearch#875
fixes algolia/vue-instantsearch#874
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.

Cannot read property 'count' of undefined on refinement components
3 participants