Administration: Fix Tags screen UI inconsistencies on add/delete - #8761
Administration: Fix Tags screen UI inconsistencies on add/delete#8761SainathPoojary wants to merge 23 commits into
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
9f820be to
ae6352a
Compare
PR removed this; needed for accessibility.
Simplifies and avoids repetition.
|
I made some refinements to this, but I'm in doubt whether it will be ready in time for 6.9. One issue was that the previous force push had overwritten some previous accessibility improvements; you'll want to be a bit more careful when merging prior changes in. |
itzmekhokan
left a comment
There was a problem hiding this comment.
Thanks for pushing this forward — the client-side/PHP sync approach is the right direction, and the delete → empty-state → re-add cycle works well when the screen already has tags on load.
I dug into why the recent test reports (#20, and earlier #2/#8) still flag the empty-state and count behaviour, and it comes down to three concrete issues in updateTableNavCount(). I've left a single inline suggested change that addresses all three:
1. colspan="5" is hardcoded. Core renders the empty-state row with colspan="<?php echo $this->get_column_count(); ?>" (class-wp-list-table.php:1721) — total columns minus those hidden via Screen Options. 5 only matches the default Posts-tag table with every column visible; hide a column, or view a taxonomy/plugin with a different column set, and the “No tags found.” cell spans the wrong width.
2. The count is parsed with .text().match(/\d+/). Core prints it with number_format_i18n() (class-wp-list-table.php:1046), so on a site with more than 999 tags the value is grouped (e.g. “1,234 items”) and the regex reads 1. Stripping non-digits before parseInt() reads the real number regardless of the locale's separator.
3. Empty-state keys off “no rows on this page” instead of “no items at all”. $('#the-list tr').length === 0 is true as soon as the current page is emptied, so on a multi-page list deleting the visible rows shows “No tags found.” and hides the nav while the count still reads e.g. “15 items”. Keying on the running total (itemCount < 1) keeps them consistent.
Two smaller things folded in: reuse core's existing _n( '%s item', '%s items', … ) string (translators have already translated the %s form) instead of a new '%d item', and guard the decrement against a negative count.
Known remaining limitations (I believe acceptable to defer)
- Pagination page-links across the per-page threshold still aren't rebuilt — this matches your note in comment #13 that a bulk-add exceeding the current page size is an edge case and shouldn't block the improvement. Worth a follow-up, not this PR.
- Adding a tag to a screen that had zero tags on initial load can't fully populate the item count / bulk actions, because when
has_items()is false core skips the bulk-actions markup andpagination()renders nothing, so.displaying-numisn't in the DOM to update (display_tablenav(),class-wp-list-table.php:1031). The delete-to-zero-then-add cycle works because that markup was rendered on load. Fully covering the from-empty case would need the add-tag AJAX response to return the pagination/bulk-action markup (or aWP_List_TableAJAX refresh) — a larger change I'd suggest tracking separately rather than expanding this PR.
Co-authored-by: Khokan Sardar <itzmekhokan@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the Tags admin screen’s client-side add/delete behavior to keep the list table UI in sync without requiring a full page reload.
Changes:
- Update the “displaying-num” count when tags are added/removed via AJAX.
- Hide/show
.tablenavand the search box when transitioning between empty/non-empty states. - Show the “No tags found.” empty-state row immediately after deleting the last tag via JavaScript.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Renders bulk actions in a `hidden` state when no items, so they're available immediately. Impacts all list table screens, but I don't think it should have any significant impact. Fixes counts to use formatted count, hides only elements inside `.tablenav` so that the tablenav spacing is left intact, avoiding the 32px shift when it's removed.
I meant to fix that before committing.
|
LGTM 👍 |
Improve AJAX interactions in the user interface when adding or removing tags by exposing the default `No tags found` row and removing bulk actions and search when the last tag is removed, and by showing bulk actions when tags are added, and incrementing item counts when adding or deleting. Developed in #8761 Props sainathpoojary, sirlouen, rishabhwp, yashjawale, wildworks, madhavishah01, khokansardar, joedolson. Fixes #63372. git-svn-id: https://develop.svn.wordpress.org/trunk@62843 602fd350-edb4-49c9-b593-d223f7449a82
Improve AJAX interactions in the user interface when adding or removing tags by exposing the default `No tags found` row and removing bulk actions and search when the last tag is removed, and by showing bulk actions when tags are added, and incrementing item counts when adding or deleting. Developed in WordPress/wordpress-develop#8761 Props sainathpoojary, sirlouen, rishabhwp, yashjawale, wildworks, madhavishah01, khokansardar, joedolson. Fixes #63372. Built from https://develop.svn.wordpress.org/trunk@62843 git-svn-id: http://core.svn.wordpress.org/trunk@62123 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This PR fixes:
.tablenavsections when no tags are present..tablenavsections when a new tag is added via JS if none previously existed.Trac ticket: #63372
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.