-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix logic in Paginator hasNextPage() method. #1467
base: dev-master
Are you sure you want to change the base?
Conversation
@@ -117,7 +117,11 @@ Y.mix(PaginatorCore.prototype, { | |||
@return {Boolean} `true` if there is a next page, `false` otherwise. | |||
*/ | |||
hasNextPage: function () { | |||
return (!this.get('totalItems') || this.get('page') < this.get('totalPages')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or return this.get('totalItems') && (this.get('page') < this.get('totalPages'));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh. I misunderstood the intent of the code.
You can see in the API docs for the method that if 'totalItems' isn't set, Paginator assumes there is always a next page. I guess this is to simulate infinite result sets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lsmith That's correct. In the event that it is bound to a datasource with an unknown upper limit (ie a search page, or email inbox)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like I can check if this.get('totalItems') === 0
either because 0 is "unset" for that attribute, right?
Searches returning 0 results is a very real case, though. Need a way to deal with this.
I'm having trouble running Update: works now after running |
@@ -4,7 +4,7 @@ Paginator Change History | |||
@VERSION@ | |||
------ | |||
|
|||
* No changes. | |||
* Fix hasNextPage() method. Previously failing when totalItems = 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"* hasNextPage() now correctly reports false when there are no items to be paged over."
items to be paged over. Previously was not working when totalItems is 0.
Previously was not working when totalItems is 0.