GriddleGriddle / Griddle

Simple Grid Component written in React
http://griddlegriddle.github.io/Griddle/
MIT License
2.5k stars 378 forks source link

Wrong number of pages in pagination if total page size is less than 2 #776

Open aftabnaveed opened 6 years ago

aftabnaveed commented 6 years ago

Griddle version

1.9.0

Expected Behavior

When total page number of records on a page in pagination is less than the page size than it should only show 1 page in pagination.

Actual Behavior

When the total number of records on a page is less than the page size then the total pages in pagination are equal to the total number of records which is wrong. As a workaround I now always have to set the page size to 2 by default

Steps to reproduce

    let pageSize = 2; //there seems to be a bug in griddle if page size is less than 2 then it shows the total pages equal to total number of records
        if(this.props.pagination.total_pages > pageSize ) {
            pageSize = this.props.pagination.total_pages;
        }
pageProperties={{
        currentPage: this.props.pagination.current_page,
        pageSize: pageSize,
        recordCount: this.props.pagination.total
        }}