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

Vue - AutoScrollTop on pagination not working and pageChange event not emitted #1973

Open
gervye opened this issue May 18, 2022 · 0 comments
Labels

Comments

@gervye
Copy link

gervye commented May 18, 2022

Affected Projects
Vue.JS

Library Version:
1.29.0

Describe the bug

When clicking on a page number, the ReactiveList component should scroll to top (by default) and should send a pageChange event.
In my case, the scroll is not done and I never get the pageChange event.

I think I found the problem in the code of the /packages/vue/src/components/result/ReactiveList.jsx component:

hits(newVal, oldVal) {
  this.$emit('data', this.getData());
  if (this.shouldRenderPagination) {
    // called when page is changed
    if (this.isLoading && (oldVal || newVal)) {
      if (this.hasPageChangeListener) {
        this.$emit('pageChange', this.currentPageState + 1, this.totalPages);
        this.$emit('page-change', this.currentPageState + 1, this.totalPages);
      } else if (this.scrollOnChange) {
        window.scrollTo(0, 0);
      }
    }

I can be wrong but I think that the line
if (this.isLoading && (oldVal || newVal)) {

should be

if (!this.isLoading && (oldVal || newVal)) {

It's missing a NOT before this.isLoading. Else it will never execute the code that is following the condition because the loading is finished since a while at this time.

@gervye gervye added the bug label May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant