Make WordPress Core

Opened 19 hours ago

Last modified 16 hours ago

#66315 new defect (bug)

Update counts in the folded admin menu don't refresh after updating a plugin

Reported by: dlocc Owned by:
Priority: normal Milestone: Awaiting Review
Component: Upgrade/Install Version:
Severity: minor Keywords: has-patch
Cc: Focuses: javascript, administration

Description

When the admin menu is folded, the update count next to "Plugins" doesn't change after you update a plugin on the page. It keeps the old number until you reload.

The admin menu prints each top-level item's update count twice: once in the menu link, and once in the submenu header (.wp-submenu-head). The submenu header is what shows when the menu is folded, either after clicking "Collapse Menu" or automatically on screens between 783 and 960 pixels wide. wp.updates.refreshCount() only updates the copy in the menu link, so the folded menu never changes.

Steps to reproduce

  1. Have two plugins with updates available.
  2. Make the browser window about 900 pixels wide, or click "Collapse Menu".
  3. Go to "Plugins > Installed Plugins" and click "update now" for one of them.
  4. Hover over "Plugins" in the admin menu.

Expected: the count shows 1.

Actual: it still shows 2. After updating both plugins it still shows 2 instead of no count.

The same thing happens with the "Themes" count in the network admin, which is also a top-level menu item. On a single site the theme count is on the "Themes" submenu item, so it isn't affected.

Environment

  • WordPress: 7.2-alpha (trunk)
  • Browser: Chromium 149
  • Single site and multisite

I have a patch ready and will link the PR here.

Attachments (2)

network-fix-after-first-update.png​ (39.1 KB ) - added by dlocc 19 hours ago.
See how the menu items indicates an update still available meanwhile the update just ran
folded-menu-count-before-after.png​ (113.3 KB ) - added by dlocc 19 hours ago.
Attached folded-menu-count-before-after.png, which shows the folded "Plugins" menu before and after the patch. The earlier attachment (network-fix-after-first-update.png) is from a patched run after 1 of 2 updates, so its "1" is correct and doesn't show the bug.

Download all attachments as: .zip

Change History (4)

@dlocc
19 hours ago

See how the menu items indicates an update still available meanwhile the update just ran

This ticket was mentioned in ​PR #14290 on ​WordPress/wordpress-develop by ​@dlocc.


19 hours ago
#1

  • Keywords has-patch added

When the admin menu is folded, the update count next to "Plugins" doesn't change after an in-page update. It keeps the old number until the page is reloaded.

The admin menu prints each top-level item's update count twice: once in the menu link, and once in the submenu header (.wp-submenu-head). The submenu header is what shows when the menu is folded, either after clicking "Collapse Menu" or automatically on screens between 783 and 960 pixels wide. wp.updates.refreshCount() only updated the copy in the menu link.

This adds the submenu header counts for the Plugins and Appearance menus to the elements refreshCount() updates. Appearance matters in the network admin, where "Themes" is a top-level item with its own count. On a single site the theme count is on the "Themes" submenu item, which has no submenu header copy.

Testing Instructions

  1. Have two plugins with updates available, for example npm run env:cli -- plugin install classic-editor --version=1.6.3 --force and npm run env:cli -- plugin install classic-widgets --version=0.2 --force.
  2. Make the browser window about 900 pixels wide, or click "Collapse Menu".
  3. Go to "Plugins > Installed Plugins" and click "update now" for one plugin.
  4. Hover over "Plugins" in the admin menu. Before: 2. After: 1.
  5. Update the other plugin and hover again. Before: still 2. After: no count.
  6. On multisite, repeat in "Network Admin > Plugins", and with an outdated theme in "Network Admin > Themes" (for example npm run env:cli -- theme install twentytwentyfour --version=1.0 --force).

I tested this on single site and multisite, with the menu folded automatically at 900 pixels and with "Collapse Menu" at 1280 pixels. Found while testing #62212.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Finding the cause, writing the patch, and scripted browser testing (Playwright) against a local wordpress-develop environment. I reviewed the code and the test results before submitting.

@dlocc
19 hours ago

Attached folded-menu-count-before-after.png, which shows the folded "Plugins" menu before and after the patch. The earlier attachment (network-fix-after-first-update.png) is from a patched run after 1 of 2 updates, so its "1" is correct and doesn't show the bug.

​@therssoftware commented on ​PR #14290:


16 hours ago
#2

Testing Feedback

I tested this both in the PR Playground instance and with DOM unit testing:

  • Before the patch:
    • When the admin menu is collapsed/folded, hovering over Plugins displays the submenu flyout with .wp-submenu-head.
    • Calling wp.updates.decrementCount( 'plugin' ) decrements the top-level link count from 2 to 1, but .wp-submenu-head .plugin-count remains stuck at 2.
    • When reaching 0 updates, the top-level badge disappears, but .wp-submenu-head continues to display the stale badge until a full page reload.
  • After the patch:
    • wp.updates.decrementCount( 'plugin' ) decrements both a[href="plugins.php"] .plugin-count and #menu-plugins .wp-submenu-head .plugin-count synchronously from 2 to 1.
    • Decrementing to 0 cleanly removes .update-plugins from both the top-level link and the submenu header.
    • The same fix applies to #menu-appearance .wp-submenu-head .update-plugins for Multisite Network Admin.

---

Suggested Test Addition

In tests/qunit/wp-admin/js/updates.js, the fixture already provides the .wp-submenu-head HTML markup for #menu-plugins. We can add assertions to decrementCount to prevent future regressions:

`javascript
In tests/qunit/wp-admin/js/updates.js -> QUnit.test( 'decrementCount correctly decreases the update number' ):
var submenuHeadCount = $( '#menu-plugins .wp-submenu-head' ).find( '.plugin-count' ).text();
assert.equal( submenuHeadCount, 2, 'Initial submenu head value is correct' );

wp.updates.decrementCount( 'plugin' );

submenuHeadCount = $( '#menu-plugins .wp-submenu-head' ).find( '.plugin-count' ).text();
assert.equal( submenuHeadCount, 1, 'Submenu head count is updated when menu is folded' );

Decrement to zero and verify both copies are removed.
wp.updates.decrementCount( 'plugin' );
assert.equal( $( '#menu-plugins' ).find( '.plugin-count' ).length, 0, 'Both menu and submenu head counts removed when zero updates remain' );

Note: See TracTickets for help on using tickets.