kouts / vue-dataset

A set of Vue.js components to display datasets (lists) with filtering, paging, and sorting capabilities!
https://next--vue-dataset-demo.netlify.app/
MIT License
220 stars 26 forks source link

Issues with # entries to show and page focus. #90

Closed pieterjandebruyne closed 2 years ago

pieterjandebruyne commented 2 years ago

Hi,

I implemented your libary but when I started testing with some more data I found the following issues:

sidenote: you can also see that when we switch from 100 -> 25 the pagenr 3 stays active. because of this item 50-74 gets rendered. I think this is a bit weird. I think switching the amount of items should always preserve the first item and add the amount needed after that. eg.

I made a codepen/screencast so you can see this issue for yourself: https://codesandbox.io/embed/vue-2-playground-forked-0rgcdo?fontsize=14&hidenavigation=1&theme=dark

https://user-images.githubusercontent.com/9568274/183077655-71ef63a6-d3bc-4b51-8347-d3560b9451ef.mov

Vue @ 2.6.12 -> tried with latest version too but issue still exists vue-dataset @ 1.1.15 -> issue seems to exists from all versions > 1.1.5 (lower versions can not run the code as is.)

Hope you can find a solution for this issue since I really like how this component is made apart from this.

Thanks for your work & time!

pieterjandebruyne commented 2 years ago

I did some more testing and it seems to trigger as soon as dsShowEntries / totalEntries < 4 (so when we have less then 5 pages.)

changing the 100 to 63 gives te same issue, 62 is fine. Using 250 entries that is 250/63 = 3.968 (= 4 pages) | 250/62=4.032 (= 5 pages).

I did some tests with other values and the issue indeed seems to happen any time we have < 5 pages.

The easiest way to reproduce is to change the amount of items to 400 and then to 400+ and keep the show 100 by default.

pieterjandebruyne commented 2 years ago

Extra side note: If we have an array of 30 items and do not pass ds-show-entries (so it takes the default of 10) it works as intended. if we pass :ds-show-entries="10" it also works. changing it to ds-show-entries="11" breaks the component.

kouts commented 2 years ago

Hey @pieterjandebruyne thanks for the detailed explanation. This seems to be indeed a bug when handling the case of the pages after the change in the "Show X entries" dropdown are less than the pages before the change. I think I can push an easy fix sometime soon, but it will probably not contain "display the first item and add the amount needed after that" logic.

kouts commented 2 years ago

The issue with the number of entries should be now fixed in https://github.com/kouts/vue-dataset/tree/v1.1.16 @pieterjandebruyne let me know if that worked for you.

pieterjandebruyne commented 2 years ago

@kouts that seems to have fixed the issue. Thanks for the quick fix!