From 9f05ce192e5502c862b55638e09d970a822fdaa2 Mon Sep 17 00:00:00 2001 From: French Ben Date: Wed, 28 Oct 2015 14:37:02 -0700 Subject: [PATCH] Added reset of pagination for new search. Fixes #1151 Signed-off-by: French Ben --- src/components/NewContainerSearch.react.js | 16 ++++++++++------ src/stores/RepositoryStore.js | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/NewContainerSearch.react.js b/src/components/NewContainerSearch.react.js index 19aed8cb..06b72dc9 100644 --- a/src/components/NewContainerSearch.react.js +++ b/src/components/NewContainerSearch.react.js @@ -66,16 +66,21 @@ module.exports = React.createClass({ _searchPromise.cancel(); _searchPromise = null; } - - let previousPage = (page - 1 < 1) ? 1 : page - 1; - let nextPage = (page + 1 > this.state.totalPage) ? this.state.totalPage : page + 1; + let previousPage, nextPage, totalPage = null; + // If query remains, retain pagination + if (this.state.query === query) { + previousPage = (page - 1 < 1) ? 1 : page - 1; + nextPage = (page + 1 > this.state.totalPage) ? this.state.totalPage : page + 1; + totalPage = this.state.totalPage; + } this.setState({ query: query, loading: true, currentPage: page, previousPage: previousPage, - nextPage: nextPage + nextPage: nextPage, + totalPage: totalPage }); _searchPromise = Promise.delay(200).cancellable().then(() => { @@ -174,8 +179,7 @@ module.exports = React.createClass({ {this.state.currentPage} (current) ); - - paginateResults = next.length || previous.length ? ( + paginateResults = (next.length || previous.length) && (this.state.query !== '') ? (