-
Notifications
You must be signed in to change notification settings - Fork 530
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
Labels
Comments
@vvo per your request. |
bobylito
changed the title
Pagination widget showNext and showLast disable problem (v1)
Pagination widget showNext and showLast disable problem
Oct 18, 2017
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
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
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
The text was updated successfully, but these errors were encountered: