#42763 closed enhancement (fixed)
class-wp-list-table unnecessarily disables first and last pagination buttons
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch commit |
Focuses: | ui, administration | Cc: |
Description
protected function pagination($which) in class-wp-list-table.php unnecessarily disables the << pagination button if you are on page 2 and disabled the >> pagination button if you are on the next to last page. That seems a bit pedantic and completely unnecessary.
If I am on page 2 of a multi-page list, I should be able to click either << or < to get back to the first page. If I am on the next to last page, I should be able to click either > or >> to get to the last page. It does not make sense to disable buttons that should logically work in these two conditions.
The following code starting at line 743 of class-wp-list-table.php...
<?php if ( $current == 1 ) { $disable_first = true; $disable_prev = true; } if ( $current == 2 ) { $disable_first = true; } if ( $current == $total_pages ) { $disable_last = true; $disable_next = true; } if ( $current == $total_pages - 1 ) { $disable_last = true; }
...should be changed too...
<?php if ( $current == 1 ) { $disable_first = true; $disable_prev = true; } if ( $current == $total_pages ) { $disable_last = true; $disable_next = true; }
Attachments (6)
Change History (19)
#3
@
6 years ago
- Keywords reporter-feedback added
I haven't tracked down where or why it happened... but the code was reverted back to its original form; the extra if() statements are back.
#7
@
5 years ago
- Keywords needs-testing added; reporter-feedback needs-refresh removed
- Version 4.9.1 deleted
updated patch
#9
@
4 years ago
- Keywords commit added; needs-testing removed
- Owner set to audrasjb
- Status changed from new to accepted
42763.2.diff
works fine (see the video capture I shared above) and it makes sense to me. Marking this ticket for commit
.
#10
@
4 years ago
Test Report
Env:
- Localhost: wp-env
- OS: macOS Big Sur v 11.6
- Browser: Chrome v 93.0.4577.82 and Firefox v 92.0
- Imported theme unit test xml
- Set the number of items on the page to 5 with this
mu-plugin
<?php add_filter( 'edit_posts_per_page', function() { return 5; } );
Test Before
Steps:
- Go to
Posts
page - Click the next page
›
button => should go to Page 2 - On Page 2, notice that the first page
«
button is disabled - Click on the last page
»
button => should go to the last page - Click on the previous page
‹
button - Notice the last page
»
button is disabled
Results:
- First page button is disabled when on Page 2 ✅
- Last page button is disabled when on last page - 1 ✅
Able to reproduce ✅
After applying patch
Steps:
- Applied 42763.2.diff patch
- Repeat steps above; however this time the first and last page buttons should remain enabled
Results:
- First page button is enabled when on Page 2 ✅
- Last page button is enabled when on last page - 1 ✅
Works as expected ✅
#11
@
4 years ago
- Owner changed from audrasjb to hellofromTonya
- Status changed from accepted to assigned
Reassigning to me for commit.
Agree with wp_kc there is not need of more conditions regarding this functionality and applied patch for it .