Skip to content

Administration: Use the taxonomy's not_found label when the last term is deleted via AJAX. - #15966

Open
umeshnevase wants to merge 1 commit into
WordPress:trunkfrom
umeshnevase:fix/term-list-empty-state-label
Open

umeshnevase wants to merge 1 commit into
WordPress:trunkfrom
umeshnevase:fix/term-list-empty-state-label

Conversation

@umeshnevase

@umeshnevase umeshnevase commented Nov 13, 2026 •

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/66693

Summary

When the last term in a taxonomy list table was removed with the AJAX Delete link, tags.js inserted an empty-state row with the hardcoded string "No tags found.". This was shown for every taxonomy, so Categories and custom taxonomies displayed the wrong message until the page was reloaded, when WP_Terms_List_Table::no_items() printed the correct label.

Localize the current taxonomy's not_found label for the admin-tags script on edit-tags.php and use it for the empty-state row. The label is inserted as text, because it is filterable and may contain markup. If the data is missing, fall back to a generic "No items found." string.

Adds an end-to-end test that deletes the last matching term on the Categories and Tags screens and checks the empty-state message.

After [62843] (#63372), deleting the last term in a taxonomy list table via the AJAX Delete link inserts an empty-state row with the hardcoded string "No tags found.". This is shown for every taxonomy, so Categories and custom taxonomies display the wrong message until the page is reloaded. On a reload, WP_Terms_List_Table::no_items() prints the taxonomy's labels->not_found.

Changes

  • src/wp-admin/edit-tags.php: localize the current taxonomy's not_found label as tagsL10n.notFound for the admin-tags script.
  • src/js/_enqueues/admin/tags.js: build the empty-state row with that label instead of the hardcoded string.
    • The label is inserted with .text(), because it is filterable and may contain markup.
    • If the data is missing, it falls back to "No items found.".
  • tests/e2e/specs/taxonomies.test.js: new test that deletes the last matching term on the Categories and Tags screens and checks the empty-state message.

Testing instructions

  1. Go to Posts > Categories (/wp-admin/edit-tags.php?taxonomy=category).
  2. Add a category, then search for it so it is the only result.
  3. Delete it with the Delete link and confirm.
  4. Before: the row reads "No tags found.". After: it reads "No categories found.".
  5. Repeat on Posts > Tags (should read "No tags found.") and with a custom taxonomy that has a not_found label (should show that label).

After fix:

after-fix

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Locating the cause of the wrong empty-state message, drafting the fix in tags.js and edit-tags.php, drafting the e2e test, and drafting this description. I reviewed and tested the changes myself before submitting.

…rm is deleted via AJAX.

When the last term in a taxonomy list table was removed with the AJAX Delete link, `tags.js` inserted an empty-state row with the hardcoded string "No tags found.". This was shown for every taxonomy, so Categories and custom taxonomies displayed the wrong message until the page was reloaded, when `WP_Terms_List_Table::no_items()` printed the correct label.

Localize the current taxonomy's `not_found` label for the `admin-tags` script on `edit-tags.php` and use it for the empty-state row. The label is inserted as text, because it is filterable and may contain markup. If the data is missing, fall back to a generic "No items found." string.

Adds an end-to-end test that deletes the last matching term on the Categories and Tags screens and checks the empty-state message.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props umeshnevase.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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.

1 participant