Skip to content

Commit

Permalink
TT#136707 Pagination - Persisted page is out of sync with actual data…
Browse files Browse the repository at this point in the history
… state

Steps to reproduce the issue:
* open any page with AuiDataTable like Domains.
* change the local storage entry for that page ( "aui_datatableOptions-domainList-domains" entry ). There you should set "page" to a bigger value than last page. Like if you have only 5 items on the domains page, set page #2
* refresh the page.
* the issue is you will not see the pagination control

Change-Id: Ic063e490071f58cff4a0dffb668e20fc376c95b3
  • Loading branch information
svleonenko authored and hpherzog committed Aug 24, 2021
1 parent 8ce55b0 commit 733c676
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/AuiDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export default {
return this.getNormalizedPagination(this.internalPagination)
},
rows () {
return this.$store.state.dataTable[this.tableId + 'Rows']
return this.$store.state.dataTable[this.tableId + 'Rows'] || []
},
internalColumns () {
const internalColumns = _.cloneDeep(this.columns)
Expand Down Expand Up @@ -626,6 +626,18 @@ export default {
pagination
})
pagination.rowsNumber = this.$store.state.dataTable[this.tableId + 'Pagination']?.rowsNumber
// Workaround to overcome absent pagination in q-table if we do not have items on page > 1.
// Switching to page # 1 by force.
// Example: it might happen if we requesting the last page but there were some changes in the system
// and some items were deleted, so the entire list becomes smaller. OR filter+pagination were
// stored in LocalStorage but the combination does not return any record from the API anymore.
if (pagination.page > 1 && this.rows.length === 0) {
pagination.page = 1
await this.requestData({
filter,
pagination
})
}
}
this.internalFilter = filter
this.internalPagination = this.getNormalizedPagination(pagination)
Expand Down

0 comments on commit 733c676

Please sign in to comment.