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

Disable "Next" button in Paginator when the next page is empty #2114

Merged
merged 14 commits into from
Sep 7, 2023

Conversation

noskla
Copy link
Contributor

@noskla noskla commented Sep 4, 2023

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.

@noskla noskla changed the title Disable "Next" button in Paginator Disable "Next" button in Paginator when the next page is empty Sep 4, 2023
Copy link
Member

@SleeplessOne1917 SleeplessOne1917 left a 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.

Copy link
Member

@dessalines dessalines left a 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}
Copy link
Member

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?

Copy link
Contributor Author

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}
Copy link
Member

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?

Copy link
Member

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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@dessalines dessalines merged commit d98009c into LemmyNet:main Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants