-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(#10210): Hide pager when there is only one page (#10210) #10221
Fix(#10210): Hide pager when there is only one page (#10210) #10221
Conversation
Hi @RayBB & @mekarpeles, I’ve implemented the fix to hide the pager when there’s only one page. Let me know if any changes are needed or if it’s good to merge. On a related note, I noticed that other pages like Trending hide the "First/Previous" buttons on the first page and the "Next/Last" buttons on the last page. Would you like me to include this behavior here, or should we address it in a separate issue? Trending Page Behaviour For your reference, I’ve already run the tests locally using:
->All tests passed successfully, you can see below Thanks again for your guidance and support @RayBB —it’s been great working with you! |
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.
Great work on the feature—it's coming along nicely! I noticed the pager is being hidden using CSS. While that works technically, it might not be the easiest approach for someone looking at the HTML to quickly understand what's going on.
For simplicity and clarity, it’s usually better to handle visibility directly in the HTML whenever possible. This way, if someone is searching for a specific element, they can find all the relevant details in one place without needing to cross-reference the CSS.
Would it be feasible to update this so the pager is hidden within the HTML itself? This small change could make the code easier to maintain and understand for future developers.
Hi @RayBB, Thanks for your feedback! I’ve looked for the HTML file where the changes could be applied, but the updates don’t seem to reflect there. It appears the pager behavior is being controlled elsewhere, and I’m not seeing the expected result in the HTML file I modified. As this is a large codebase, I’m still familiarizing myself with all the intricacies, so it would be really helpful if you could point me to the exact HTML file or location where these changes should be made. |
@SharkyBytes please check in |
151db16
to
1ccea97
Compare
I was also looking at the @RayBB, Please take a look at the changes I made, and let me know if this approach works or if you'd prefer a different solution. |
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.
Let's try using the proper JavaScript API instead of adding new css.
This is where we deal with pagers in html https://github.com/internetarchive/openlibrary/blob/master/openlibrary/macros/Pager.html#L4 (this could be Within js for the editions table, here you can see if/when we are rendering the
|
Hey @RayBB & @mekarpeles , I've updated the code to dynamically handle the pagination visibility using the DataTables API. Now, the pagination controls are hidden when the total row count is less than or equal to the selected page length or when 'All' is selected in the dropdown. Let me know if there's anything else you'd like me to tweak! |
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 like a step in the right direction!
Can you please remove all the whitespace changes you've made so it's easy to see the needed changes? You might need to disable automatic code formatting in your IDE if it's enabled.
Also there are now failing checks. Please address these (they're small ones).
Thanks for your patience. I know these small things can be a pain.
9c998e6
to
b06f2c7
Compare
for more information, see https://pre-commit.ci
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10221 +/- ##
==========================================
- Coverage 17.44% 17.42% -0.02%
==========================================
Files 89 89
Lines 4792 4797 +5
Branches 848 849 +1
==========================================
Hits 836 836
- Misses 3436 3439 +3
- Partials 520 522 +2 ☔ View full report in Codecov by Sentry. |
Hey @RayBB and @mekarpeles , Just a quick update — I’ve improved the logic and cleaned up the auto-formatting changes so the code looks cleaner now. All checks have passed, so it’s ready for review. Let me know if you spot anything. |
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 seems like a fantastic solution to me! Great job 👍
Hiding the element isn't ideal but I don't think there's a better way to do it.
Now we just need staff to review/merge.
I believe this change set now LGTM. 👍 thank you! |
Thanks for merging @RayBB & @mekarpeles! Really loved working on this with you both. Appreciate your support and feedback throughout :) |
Closes #10210
Fix: Hides the pager when there is only one page in the
legacy-datatables
UI. This prevents unnecessary pagination buttons that serve no purpose for users.Technical
Testing
Screenshot
Pager Hidden (Single Page):
The pager is hidden because the allowed entries are more than the actual dataset (8 entries).
Pager Visible (Multiple Pages):
The pager is shown when the dataset exceeds the allowed entries.
Stakeholders
@RayBB