Make WordPress Core

Opened 16 months ago

Closed 4 weeks ago

#63372 closed defect (bug) (fixed)

Tags page UI inconsistencies when adding or deleting tags

Reported by: sainathpoojary Owned by: joedolson
Priority: normal Milestone: 7.1
Component: Administration Version:
Severity: normal Keywords: has-patch has-test-info commit
Cc: Focuses: ui, accessibility, javascript, css

Description (last modified by khokansardar)

There are several UI issues on the Tags page in the WordPress admin when adding or deleting tags:

1. "No tags found." message not shown after last tag is deleted:
When all tags are removed using the JavaScript interface, the message "No tags found." does not appear until the page is manually refreshed. Also, the .tablenav sections (top and bottom) are not removed immediately and remain visible until refresh.

2. Bulk action and item count does not reappear when a new tag is added via JS:
If there are no tags and a new tag is added using the input form (handled via JavaScript), the .tablenav sections remain hidden and do not reappear unless the page is refreshed.

3. Pagination count not updated:
When tags are added or deleted via JavaScript and the tag list is paginated, the pagination count is not updated accordingly. This leads to inconsistencies between the actual number of tags and what's shown in the pagination controls.

These issues appear to stem from the fact that while tag creation and deletion are handled client-side via JavaScript, updates to .tablenav visibility and pagination count are handled by PHP and only rendered on full page reload.

Steps to reproduce

  1. Go to Posts > Tags.
  2. Delete all tags using the delete links in the table (handled via JS).
    • Notice that the "No tags found." message does not appear.
    • .tablenav sections remain visible.
  3. Refresh and Add a new tag using the "Add New Tag" form.
    • The new tag appears in the list via JavaScript.
    • However, the .tablenav sections remain hidden and do not reappear.
  4. Add or delete tags while viewing a paginated list.
    • The pagination count does not reflect the updated number of tags.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 135.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.2
  • MU Plugins: None activated
  • Plugins: Test Reports 1.2.0

Screencast

https://rioudcpuyg.ufs.sh/f/PL8E4NiPUWyOaBpE7dHJcb5UXrLqDIo97jZKdMWg8iplmysR

Change History (30)

This ticket was mentioned in PR #8761 on WordPress/wordpress-develop by @sainathpoojary.


16 months ago
#1

  • Keywords has-patch added

This PR fixes:

  • Display the "No tags found." message immediately when the last tag is deleted via JavaScript.
  • Hide .tablenav sections when no tags are present.
  • Show .tablenav sections when a new tag is added via JS if none previously existed.
  • Ensure pagination count is updated dynamically when tags are added or removed.

Trac ticket: #63372

#2 @SirLouen
16 months ago

  • Keywords changes-requested has-testing-info added

Combined Reproduction and Patch Test Report

Description

This report can't validate that the indicated patch works completely as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8761.diff

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 135.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-One 2.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Reproduction Steps

  • Screen Options ⇒ Fixed to Number of items per page (10) for pagination
  • Create some tags
  • Remove all tags
  • 🐞 First bug reproduced (no "No tags found", message)
  • Start adding tags
  • 🐞 Second bug reproduced (tablenav appears)
  • 🐞 Third bug reproduced The number of items don't update
  • 🐞 Extra potential bug: When reaching the fixed number of items per page (10 in my case), pagination doesn't appear when we have more than 10 items, until we refresh.

Expected results

  1. When all tags are removed, "No tags found" should appear
  2. The tablenav should appear as soon as there are new tags to be able to deal with them
  3. The number of items should update every new tag we create
  4. Reaching the Number of items per page, should add a pagination control.

Actual Results with Patch

  1. ✅ "No tags found" appears correctly when all tags removed
  2. tablenav still doesn't appear after adding new tags
  3. ❌ Number of items don't appear
  4. ❌ With a refresh number of items appear, but they don't update with each new tag
  5. ❌ When reaching the "Number of items per page", the pagination control still doesn't appear without refresh.

Additional Notes

Added a screencast to showcase the problems that still exist

Supplemental Artifacts

Screencast: https://streamable.com/zdp0ro

Version 0, edited 16 months ago by SirLouen (next)

#3 @joedolson
16 months ago

  • Focuses accessibility added

#4 @wordpressdotorg
15 months ago

  • Keywords has-test-info added; has-testing-info removed

#5 @sainathpoojary
14 months ago

  • Keywords changes-requested removed

Thanks for the detailed test report @SirLouen! I’ve since updated the PR to address all reported issues, and it’s now ready for review.

#6 @SirLouen
14 months ago

  • Keywords needs-testing added

#7 @rishabhwp
14 months ago

Reproduction Report

Description

This report validates whether the issue can be reproduced.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 137.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty 2.9
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ Error condition occurs (reproduced).

Supplemental Artifacts

https://ifnmp28oya.ufs.sh/f/0nfskUTEKfUZUOlu5SNmYySW2Gs6Vh5nKvcp49ITxeMZNwbA

#8 @yashjawale
14 months ago

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8761.diff

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 137.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-One 2.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ "No tags found" appears correctly when all tags removed
  2. ✅ tablenav appears after adding new tags
  3. ✅ Number of items appear
  4. ✅ The number of items update with each operation
  5. ❌ When reaching the limit "Number of items per page", the pagination control still doesn't appear without refresh.

Additional Notes

  • In general, when adding/deleting tags, the pagination doesn't update accordingly. eg. if viewing a fixed number of tags & deleting all of them, the next set of tags don't appear until full page refresh

Supplemental Artifacts

Screencast: https://files.catbox.moe/40dqpy.mov

#9 @SirLouen
14 months ago

  • Keywords changes-requested added; needs-testing removed

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


14 months ago

#11 @joedolson
14 months ago

  • Owner set to joedolson
  • Status newaccepted

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


12 months ago

#13 @joedolson
12 months ago

  • Milestone Awaiting Review6.9

Since this has a pretty well-progressed patch, I'm going to milestone this for 6.9; it seems within reach to get finished soon.

Regarding the missing point - while that would be nice to have, I'd also say it's somewhat of an edge case. It would only occur if somebody adds more terms via AJAX than their current pagination limits, and the actions of adding tags in bulk are fairly separate from the actions of exploring your tags.

It would be good to get it fixed, but this would still be a significant improvement without that, so it shouldn't necessarily block it from moving forward.

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


11 months ago

This ticket was mentioned in Slack in #accessibility by a.k._azad. View the logs.


10 months ago

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


10 months ago

@joedolson commented on PR #8761:


10 months ago
#17

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.

#18 @wildworks
9 months ago

  • Milestone 6.97.0

Since the 6.9 RC1 release is coming soon, I will punt this ticket to 7.0.

However, if you can complete the pull request before RC1, please revert the milestone and feel free to move forward.

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


7 months ago

#20 @madhavishah01
6 months ago

Tested on the latest 7.0-beta1 version with patch, default theme active, no other plugins.

I’m able to reproduce the issues even after applying patch.

1. Empty state not updating
After deleting the final tag, the table becomes blank but the “No tags found.” message does not appear until a manual refresh.

2. Pagination count not updating
With 25+ tags (multiple pages), deleting tags via AJAX does not update pagination counts dynamically. Page numbers remain unchanged until manual refresh.

Screenshot for reference:
https://prnt.sc/nwNbLMsKL0As

Last edited 6 months ago by madhavishah01 (previous) (diff)

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


6 months ago

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


6 months ago

#23 @joedolson
6 months ago

  • Milestone 7.07.1

This is still viable for 7.1.

#24 @joedolson
6 months ago

#64815 was marked as a duplicate.

#25 @khokansardar
6 weeks ago

  • Description modified (diff)

Left a code review on PR #8761 with an inline suggested change to updateTableNavCount() in src/js/_enqueues/admin/tags.js, addressing the empty-state and count issues still flagged in the recent test reports (comments #20, #2, #8):

  • Dynamic colspan on the "No tags found." row, computed from the visible header columns to match WP_List_Table::get_column_count(), instead of the hardcoded colspan="5" (only correct for the default column set).
  • i18n-safe count parsing — the count is rendered with number_format_i18n(), so on sites with 1,000+ tags the previous match(/\d+/) read "1,234 items" as 1.
  • Empty-state keyed on the item total (itemCount < 1) rather than the current page's row count, so a multi-page list no longer shows "No tags found." while the count still reads e.g. "15 items".

Also reuses core's existing _n( '%s item', '%s items', … ) string and guards against a negative count.

Two limitations remain, which I believe are acceptable to defer:

  • Pagination page-links crossing the per-page threshold are still not rebuilt — consistent with @joedolson's note in comment #13 that this is an edge case and shouldn't block the improvement.
  • Adding a tag when the screen had zero tags on initial load can't fully populate the count/bulk actions, since that markup isn't rendered server-side when has_items() is false. Fully covering it would need the add-tag AJAX response to return the pagination/bulk-action markup — better tracked as a follow-up.

Review: https://github.com/WordPress/wordpress-develop/pull/8761#pullrequestreview-4678074921

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


4 weeks ago

#27 @joedolson
4 weeks ago

I added a change that renders a zero item indicator instead of an empty string when there are no items and renders the bulk actions container as hidden when there are no items.

I also changed the hiding behavior to only hide the contents inside .tablenav, to avoid unexpected shifts in location.

While this doesn't solve everything, it does improve this fairly significantly. Still doesn't handle the search box or pagination, but these are only relevant in pretty obscure cases: both are only relevant use cases if somebody adds a bunch of new tags to a site without tags, and search is only relevant if they then need to search them immediately. These seem like edge cases that aren't really important to address.

While the PR now introduces new content to other post lists, as well, it only changes the empty case, and all content is hidden by default, so it seems unlikely to have a significant impact. Still, should be watched for.

@khokansardar commented on PR #8761:


4 weeks ago
#28

LGTM 👍

#29 @joedolson
4 weeks ago

  • Keywords commit added; changes-requested removed

#30 @joedolson
4 weeks ago

  • Resolutionfixed
  • Status acceptedclosed

In 62843:

Administration: Improve UI when adding or removing tags.

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 https://github.com/WordPress/wordpress-develop/pull/8761

Props sainathpoojary, sirlouen, rishabhwp, yashjawale, wildworks, madhavishah01, khokansardar, joedolson.
Fixes #63372.

Note: See TracTickets for help on using tickets.