From d6c6426aed8bf11496829506f01ad143b9830d49 Mon Sep 17 00:00:00 2001 From: Joe Wroten Date: Mon, 8 May 2017 17:45:40 -0400 Subject: [PATCH] Fixed pagination bugs --- src/components/Spelllist.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Spelllist.vue b/src/components/Spelllist.vue index 5c8e350..e125e60 100644 --- a/src/components/Spelllist.vue +++ b/src/components/Spelllist.vue @@ -51,7 +51,8 @@ Vue.component('spell-item', SpellItem) export default { computed: { pageMax () { - return this.spells.length / this.perPage + let trueMax = this.spells.length / this.perPage + return trueMax < 1 ? 1 : trueMax }, pagedSpells () { let min = this.page * this.perPage - this.perPage @@ -59,6 +60,13 @@ export default { return this.spells.slice(min, max) } }, + watch: { + pageMax (newPageMax) { + if (this.page > newPageMax) { + this.page = newPageMax + } + } + }, props: [ 'spells' ],