-
Notifications
You must be signed in to change notification settings - Fork 338
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
Disable "Next" button in Paginator when the next page is empty #2114
Conversation
…th of the array, not the array itself
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.
This is a good fix. It's probably worth doing something like this everywhere the paginator is used.
…tsx and modlog.tsx
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.
Looks good, thx!
@@ -23,6 +24,7 @@ export class Paginator extends Component<PaginatorProps, any> { | |||
<button | |||
className="btn btn-secondary" | |||
onClick={linkEvent(this, this.handleNext)} | |||
disabled={this.props.nextDisabled || false} |
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.
Is the || false
necessary here?
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.
Good catch, it's a residue after nextDisabled was optional to not pass "undefined" to the property, I'll fix it
<Paginator | ||
page={this.state.page} | ||
onChange={this.handlePageChange} | ||
nextDisabled={false} |
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.
Is there never a time that this needs to be disabled?
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 needs to be disabled when there are multiple lists (because the API doesn't combine them)
<Paginator | ||
page={page} | ||
onChange={this.handlePageChange} | ||
nextDisabled={false} |
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.
Same here.
Description
It may cause confusion to the user why pages in the community list are empty when there are no more communities to display. This small change fixes this issue by disabling the Next button if the number of fetched communities is less than the limit.
Additionally, I have moved the communityLimit constant to the config file.
Possible issues with this approach
The Next button will be still enabled, if there are exactly {communityLimit} communities on the instance, to mitigate this the API would have to tell the client if currently viewed page is last, or the client could fetch next page in advance.