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

Hits widget: transformData not always called when refining #1100

Closed
timkelty opened this issue Jun 21, 2016 · 5 comments
Closed

Hits widget: transformData not always called when refining #1100

timkelty opened this issue Jun 21, 2016 · 5 comments

Comments

@timkelty
Copy link
Contributor

When using a refinementList (or presumably other sorts of filtering), if a hit exists before and after refinement, transformData is NOT called the subsequent time(s).

Original post: http://stackoverflow.com/questions/37924976/instantsearch-js-hits-widget-transforming-data-on-refinement?noredirect=1#comment63313526_37924976

Demo: https://jsfiddle.net/timkelty/LyuL5eze/7/

@vvo
Copy link
Contributor

vvo commented Jul 8, 2016

@timkelty Revisiting this issue so basically the hits widget works like that:

  • if the hits list is 0
  • if the hits list length is different from the previous hits length
  • or if some hits are different from the previous list (deep comparison)

Then we do render the hits again and call transformData.

So yes, if the hits list is absolutely the same between two clicks then we do not re-render it.

Can I ask you what you are doing in this formatData that would require the hits to still be re-rendered? Thanks

@timkelty
Copy link
Contributor Author

timkelty commented Jul 8, 2016

In this case formatData is changing the display of the data based on refinementList criteria.
Specifically, choosing which product image is displayed (e.g. user filters "green", and an existing hit still needs to be re-rendered to display the image tagged as "green").

In this example I'm doing this by changing the value of hit.productImages: https://jsfiddle.net/timkelty/LyuL5eze/7/

@vvo
Copy link
Contributor

vvo commented Jul 11, 2016

Ok so I fixed this issue by removing any check we had on the rendering of hits, it's too tricky to try to optimize that for now.

@timkelty
Copy link
Contributor Author

Thanks, will test.

@vvo
Copy link
Contributor

vvo commented Jul 11, 2016

Not yet released, test in one hour

@vvo vvo closed this as completed in 2e7bf8a Jul 11, 2016
vvo pushed a commit that referenced this issue Jul 11, 2016
<a name="1.6.3"></a>
## [1.6.3](v1.6.2...v1.6.3) (2016-07-11)

### Bug Fixes

* **Hits:** always render hits ([2e7bf8a](2e7bf8a)), closes [#1100](#1100)
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

No branches or pull requests

2 participants