mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
fix #488
* updated test for pagination fix * suspected bug in page.js Local pagination aligning returns start page when eg editing cell locally. This results in state change, too. Not really getting the purpose of the original idea. Please consider this modification. It only checks if page fits in the data size range. As I saw, this alignment only affects local pagination, not remote. * modified fix w/ pageStartIndex I forgot to mind pageStartIndex
This commit is contained in:
parent
cb49455a4e
commit
4a3486cc3c
@ -23,10 +23,9 @@ export const alignPage = (
|
||||
sizePerPage,
|
||||
pageStartIndex
|
||||
) => {
|
||||
const end = endIndex(page, sizePerPage, pageStartIndex);
|
||||
const dataSize = data.length;
|
||||
|
||||
if (end - 1 > dataSize) {
|
||||
if (page < pageStartIndex || page > (Math.floor(dataSize / sizePerPage) + pageStartIndex)) {
|
||||
return pageStartIndex;
|
||||
}
|
||||
return page;
|
||||
|
||||
@ -45,8 +45,8 @@ describe('Page Functions', () => {
|
||||
describe('alignPage', () => {
|
||||
const pageStartIndex = 1;
|
||||
const sizePerPage = 10;
|
||||
const page = 2;
|
||||
describe('if the length of store.data is less than the end page index', () => {
|
||||
const page = 3;
|
||||
describe('if the page does not fit the pages interval calculated from the length of store.data', () => {
|
||||
beforeEach(() => {
|
||||
data = [];
|
||||
for (let i = 0; i < 15; i += 1) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user