Skip to content

Commit

Permalink
fix: Change the value of pageOffset when enabling server side paginat…
Browse files Browse the repository at this point in the history
…ion (#36056)

## Description
Fixed issue #36022 where incorrect data is displayed when navigating to
the previous page after reaching the last page with fewer items in the
table during server-side pagination enabled by using `props.pageSize`
instead of `props.tableData?.length`.


Fix:

Replaced `props.tableData?.length` with `props.pageSize` to ensure
consistent data display when navigating between pages, especially when
dealing with the last page that has fewer items than the pageSize.


Fixes #36022

## Automation

/ok-to-test tags="@tag.Table"




## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
- Improved pagination logic for the table widget, simplifying the
handling of page size.

- **Bug Fixes**
- Resolved potential inconsistencies in pagination when server-side data
is utilized.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Phennapa Saeliw <psaeliw@gmail.com>
  • Loading branch information
phennapa-saeliw and phennapa authored Oct 25, 2024
1 parent cd26aed commit 2ad374a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions app/client/src/widgets/TableWidgetV2/widget/derived.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,7 @@ export default {
},
//
getPageOffset: (props, moment, _) => {
const pageSize =
props.serverSidePaginationEnabled && props.tableData
? props.tableData?.length
: props.pageSize;
const pageSize = props.pageSize;

if (
Number.isFinite(props.pageNo) &&
Expand Down

0 comments on commit 2ad374a

Please sign in to comment.