Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination widget showNext and showLast disable problem #2014

Closed
chriscalip opened this issue Feb 28, 2017 · 2 comments
Closed

Pagination widget showNext and showLast disable problem #2014

chriscalip opened this issue Feb 28, 2017 · 2 comments

Comments

@chriscalip
Copy link
Contributor

chriscalip commented Feb 28, 2017

Requesting to backport to v1 the bug fix (Pagination widget showNext and showLast disable problem #1938) found on v2 and v3.
#1938

Do you want to request a feature or report a bug?
bug
Bug: What is the current behavior?
In Pagination widget showNext and showLast are not disabled when number of hits is 0
Bug: What is the expected behavior?
To be disabled.
Bug: What browsers are impacted? Which versions?

Feature: What is your use case for such a feature?

Feature: What is your proposed API entry? The new option to add? What is the behavior?

Calculation for total pages:
https://github.com/algolia/instantsearch.js/blob/v2.2.5/packages/react-instantsearch/src/components/Pagination.js#L110
totalPages = 0 because number of hits is 0 ->
https://github.com/algolia/instantsearch.js/blob/v2.2.5/packages/react-instantsearch/src/connectors/connectPagination.js#L48

https://github.com/algolia/instantsearch.js/blob/v2.2.5/packages/react-instantsearch/src/components/Pagination.js#L110https://github.com/algolia/instantsearch.js/blob/v2.2.5/packages/react-instantsearch/src/components/Pagination.js#L111
lastPage = 0
https://github.com/algolia/instantsearch.js/blob/v2.2.5/packages/react-instantsearch/src/connectors/connectPagination.js#L11
in searchState there is no key = page ->
https://github.com/algolia/instantsearch.js/blob/v2.2.5/packages/react-instantsearch/src/connectors/connectPagination.js#L49
currentRefinement = 1

https://github.com/algolia/instantsearch.js/blob/v2.2.5/packages/react-instantsearch/src/components/Pagination.js#L153
https://github.com/algolia/instantsearch.js/blob/v2.2.5/packages/react-instantsearch/src/components/Pagination.js#L163
disabled = false
Possible solution:
disabled: currentRefinement === lastPage || lastPage <= 1

What is the version you are using? Always use the latest one before opening a bug issue.
v1.11.2

@chriscalip
Copy link
Contributor Author

@vvo per your request.

@bobylito bobylito changed the title Pagination widget showNext and showLast disable problem (v1) Pagination widget showNext and showLast disable problem Oct 18, 2017
@bobylito
Copy link
Contributor

Could be reproduced in instantsearch.js v2: https://jsfiddle.net/bobylito/cq17ut1r/

As a side note, that's a bit of an outlier as the default behavior is to hide automatically the pagination when there are no results.

bobylito pushed a commit that referenced this issue Dec 29, 2017
bobylito added a commit that referenced this issue Dec 29, 2017
* fix(pagination): if the results contains no hits, disable the buttons
* fix(pagination): add tests for disabled behaviour
* chore: add story to test #2014
* fix(pagination): display the current if no results
We're still on page 1 after all.

fix #2014
bobylito pushed a commit that referenced this issue Jan 2, 2018
<a name=2.4.0></a>

* **pagination:** disable buttons if not results ([#2643](#2643)) ([9017b72](9017b72)), closes [#2014](#2014)
* **theme:** fix height of pagination ([#2641](#2641)) ([b3185e5](b3185e5))

* **core:** add a reload method on the InstantSearch component ([#2637](#2637)) ([e73ff13](e73ff13))
* **core:** add an error event to monitor error from Algolia ([#2642](#2642)) ([71c2d68](71c2d68)), closes [#1585](#1585)
* **core:** rename `reload` to `refresh` ([#2645](#2645)) ([9b8ac65](9b8ac65))
* **wrapWithHits:** enable async init ([#2635](#2635)) ([08a8747](08a8747))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants