appbaseio / reactivesearch

Search UI components for React and Vue
https://opensource.appbase.io/reactivesearch
Apache License 2.0
4.89k stars 466 forks source link

ReactiveList onPageChange event fired when filter applied #396

Closed nestedifsdotcom closed 6 years ago

nestedifsdotcom commented 6 years ago

Issue Type: Bug

Platform:

Web Description: i attached this event on ReactiveList onPageChange={() => { window.scrollTo({ top: 300, behavior: "smooth" }); }} The onPageChange event is fired not only on pagination change but also on filter apply (in my case checking on MultiList).

is there a way to add an event to the pagination only via reactiveSearch?

Reactivesearch version: 2.6.2

metagrover commented 6 years ago

This is an expected behavior because the results change as you update the selection on MultiList, which causes the page change event to get fired, i.e. if you are on Page 3 and you select a new item in MultiList, you will get to Page 1 in the result components.

onPageChange gets fired whenever there is a change in query, which is either triggered via page change (via interaction) or query change from the subscribed components.

Can you explain your use case - exactly when do you want to scroll to top: 300?

nestedifsdotcom commented 6 years ago

The top:300 was just for the example sake. what I want to do is to smooth scroll to the top of the ReactiveList

metagrover commented 6 years ago

okay, but when do you wish to make the page scroll to top? What kind of event should trigger the scrolling?

Should it be when the user manually interacts with the pagination buttons, or at anytime the pagination changes programmatically via query change?

nestedifsdotcom commented 6 years ago

I want it to scroll when the user manually interacts with the pagination buttons.

metagrover commented 6 years ago

For now, we will be exposing onClick handlers on pagination buttons to resolve this issue. But going further, v3 should expose the action type as a param with onPageChange to specify the cause of the event trigger. For example:

Action types can be:

QUERY_CHANGE INTERACTION

cc @divyanshu013

nestedifsdotcom commented 6 years ago

Thank you for your support

divyanshu013 commented 6 years ago

Added in v2.6.7 🤘