diff --git a/embark-ui/src/components/Pagination.js b/embark-ui/src/components/Pagination.js index ca8e003c9..2d566115c 100644 --- a/embark-ui/src/components/Pagination.js +++ b/embark-ui/src/components/Pagination.js @@ -5,13 +5,16 @@ import PropTypes from 'prop-types'; const NB_PAGES_MAX = 8; const Pages = ({currentPage, numberOfPages, changePage}) => { - let i = currentPage - NB_PAGES_MAX / 2; + let max = currentPage + NB_PAGES_MAX / 2; + if (max >= numberOfPages) { + max = numberOfPages; + } + let i = max - NB_PAGES_MAX; if (i < 1) { i = 1; } - let max = i + NB_PAGES_MAX - 1; - if (max > numberOfPages) { - max = numberOfPages; + if (max - i < NB_PAGES_MAX) { + max += NB_PAGES_MAX - max + 1; } const pageNumbers = []; for (i; i <= max; i++) { diff --git a/embark-ui/src/containers/BlocksContainer.js b/embark-ui/src/containers/BlocksContainer.js index 3e2dbe4bc..c580d70b7 100644 --- a/embark-ui/src/containers/BlocksContainer.js +++ b/embark-ui/src/containers/BlocksContainer.js @@ -13,7 +13,7 @@ class BlocksContainer extends Component { constructor(props) { super(props); - this.state = {currentPage: 1}; + this.state = {currentPage: 0}; } componentDidMount() { @@ -50,7 +50,8 @@ class BlocksContainer extends Component { 0} {...this.props} render={({blocks}) => ( this.changePage(newPage)} currentPage={this.state.currentPage} /> + changePage={(newPage) => this.changePage(newPage)} + currentPage={this.state.currentPage || this.getNumberOfPages()} /> )} /> );