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

Page change event triggered when perPage is changed #382

Closed
1 task done
josephting opened this issue Aug 31, 2018 · 4 comments
Closed
1 task done

Page change event triggered when perPage is changed #382

josephting opened this issue Aug 31, 2018 · 4 comments

Comments

@josephting
Copy link

josephting commented Aug 31, 2018

Issue Type

  • Bug

Specs

  • v2.13.2
  • Latest Chrome Stable

Expected Behavior

Changing perPage should ONLY trigger on-per-page-change event

Actual Behavior

Changing perPage triggered both on-per-page-change & on-page-change event

Steps to Reproduce the Problem

Please detail your steps here

  1. Next & Prev page is working properly with only onPerPageChange event getting triggered
  2. Changing perPage to any other perPage will trigger both onPerPageChange and onPageChange at the same time

jsfiddle

https://jsfiddle.net/Lp8xw7ec/

v2.13.0 behavior - https://jsfiddle.net/saemvn4p/

@josephting
Copy link
Author

It seems like this is intentional behavior from #371 ?
Please confirm. It feels like we're losing feature here to only change page back to 1 only when the current page exceeds the max page number after having the perPage changed.

@VictorCazanave
Copy link
Contributor

Actually this behaviour has been added in #370
I think it's more "logic" and simpler to always go to the first page when changing per page.
I don't use the on-page-change and on-per-page-change events, so I can't comment your idea of changing their order.

@josephting
Copy link
Author

josephting commented Sep 3, 2018

@VictorCazanave Got it. Thank you for your confirmation. Agreed. Going with simpler method is usually better in this case.

@xaksis I've put together a JSFiddle to highlight the issue I'm facing with using on-per-page-change and on-page-change event.

https://jsfiddle.net/8dbemzjp/

Since on-page-change event is always called regardless of page or perPage being changed, I figured I should only do a table data reload from server only on on-page-change.
However, on-page-change is returning the old currentPerPage I think because the $emit('per-page-changed') is called after the page is changed back to 1.

If there is no particular reason behind having the page changed to 1 before emitting per-page-changed, I would like to have this.changePage(1) to only be called after per-page-changed has been emitted.

Ref: https://github.com/xaksis/vue-good-table/pull/371/files#r214557822

xaksis added a commit that referenced this issue Sep 4, 2018
@xaksis
Copy link
Owner

xaksis commented Sep 4, 2018

@josephting took your recommendation. 2.13.3 has your fix.

@xaksis xaksis closed this as completed Sep 4, 2018
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

3 participants