Skip to content

Commit 38ca9ff

Browse files
committed
fix: paginate to last page if pageCount decreases
When the pageCount decreases so that it is less than the currentPage, the currentPage now gets set to the last page.
1 parent baa8255 commit 38ca9ff

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/FeathersVuexPagination.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createElement, computed } from '@vue/composition-api'
1+
import { createElement, computed, watch } from '@vue/composition-api'
22

33
export default {
44
name: 'FeathersVuexPagination',
@@ -63,6 +63,16 @@ export default {
6363
}
6464
})
6565

66+
watch(
67+
() => pageCount.value,
68+
() => {
69+
const lq = props.latestQuery
70+
if (lq && lq.response && currentPage.value > pageCount.value) {
71+
currentPage.value = pageCount.value
72+
}
73+
}
74+
)
75+
6676
const canPrev = computed(() => {
6777
return currentPage.value - 1 > 0
6878
})

0 commit comments

Comments
 (0)