Skip to content

Commit

Permalink
fix: search on the second page didn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
juliahermak committed Jan 19, 2024
1 parent 1a2aeb3 commit a79b232
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/DelegatesTable/DelegatesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ export default defineComponent({
const startIndex = (page.value - 1) * perPage.value
const endIndex = startIndex + perPage.value
const delegatesOnCurrentPage = delegates.value.slice(startIndex, endIndex)
const filteredDelegates = [...delegatesOnCurrentPage]
const filteredDelegates = [...delegates.value]
.sort(sortDelegatesByColumnCompareFn(sortBy.value))
.filter(filterDelegatesFn(searchQuery.value))
.slice(startIndex, endIndex)
return reactive(filteredDelegates)
})
Expand Down
8 changes: 7 additions & 1 deletion src/views/Votes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
import AppToolbarCentered from '@/components/AppToolbarCentered.vue'
import Pagination from '@/components/Pagination.vue'
import DelegatesTable from '@/components/DelegatesTable/DelegatesTable.vue'
import { computed, onMounted, ref, reactive, defineComponent } from 'vue'
import { computed, onMounted, ref, reactive, defineComponent, watch } from 'vue'
import { useStore } from 'vuex'
import { useI18n } from 'vue-i18n'
Expand Down Expand Up @@ -134,6 +134,12 @@ export default defineComponent({
return Math.ceil(delegates.value.length / pagination.rowsPerPage)
})
watch(search, (newValue) => {
if (newValue.length > 0) {
pagination.page = 1
}
})
const showPagination = computed(() => search.value.length === 0)
const reviewButtonDisabled = computed(() => {
return numOfUpvotes.value + numOfDownvotes.value === 0
Expand Down

0 comments on commit a79b232

Please sign in to comment.