Open patrickkivits opened 6 years ago
I found a hacky workaround that fixed it for my app. First, I added a ref
to my <paginate></paginate>
component ref="paginator"
. Then I created a computed property:
emptyArray () {
return store.state.recipes.length == 0
}
then I created a watcher that looks for a change from length == 0 to length != 0:
watch: {
emptyArray: function(newVal, oldVal) {
if ( newVal === false && oldVal === true ) {
setTimeout(() => {
if (this.$refs.paginator) {
this.$refs.paginator.goToPage(page)
}
}, 100)
}
}
}
The timeout was necessary otherwise it thought there was no page 1.
When given an empty list, the value of currentPage becomes -1.
Even when you then update the empty list with an item, the items still won't show up.
This pull request ensures there can never be a negative value for the currentPage and it will always have an minimum value of 0.
Fixes: #94