Skip to content

Forms: add awaiting-mod class to Jetpack menu feedback unread counter badge#50060

Open
enejb wants to merge 4 commits into
trunkfrom
fix/jetpack-counter
Open

Forms: add awaiting-mod class to Jetpack menu feedback unread counter badge#50060
enejb wants to merge 4 commits into
trunkfrom
fix/jetpack-counter

Conversation

@enejb

@enejb enejb commented Jun 30, 2026

Copy link
Copy Markdown
Member

Fixes JETPACK-1572

Before:

Screenshot 2026-06-29 at 6 01 10 PM

After:

Screenshot 2026-06-29 at 6 00 38 PM

Proposed changes

  • Add an optional $extra_classes parameter to Contact_Form_Plugin::get_unread_count_badge_markup() so callers can attach additional CSS classes to the feedback unread-count badge.
  • Pass the WordPress core awaiting-mod class when building the combined Jetpack top-level menu badge ($jetpack_unread_tag), so the badge uses the same markup core uses for admin-menu notification bubbles and picks up the active admin color scheme's bubble color.
  • The Jetpack → Forms submenu badge is unchanged (still bare menu-counter jp-feedback-unread-counter).

Note: the boost menu-counter change that originally started this branch was reverted; the net change in this PR is only the Forms package update above.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • Set up a site with Jetpack (and the Forms package) connected.
  • Submit at least one form so there is unread feedback (jetpack_feedback_unread_count > 0), or set it manually: wp option update jetpack_feedback_unread_count 3.
  • In wp-admin, look at the top-level Jetpack item in the admin sidebar — it shows the combined unread count as a bubble.
  • Confirm the bubble renders correctly (count visible, bubble styled) and that switching the admin color scheme (Users → Profile → Admin Color Scheme, e.g. Sunrise) tints the bubble to match the scheme.
  • Verify the Jetpack → Forms submenu still shows its own unread badge.

Note on visual impact: on a connected site under the default and alternate color schemes, the badge already renders a correctly-colored bubble via the existing jp-feedback-unread-counter class, so this change is not expected to be visually different in those cases — it aligns the markup with core's awaiting-mod convention.

…tyling

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@enejb enejb self-assigned this Jun 30, 2026
@github-actions github-actions Bot added [Plugin] Boost A feature to speed up the site and improve performance. Admin Page React-powered dashboard under the Jetpack menu labels Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Boost plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control

jp-launch-control Bot commented Jun 30, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 709/1563 (45.36%) 0.32% 0 💚

Full summary · PHP report · JS report

enejb and others added 2 commits June 29, 2026 17:45
…andard WP styling

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/jetpack-counter branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/jetpack-counter

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@enejb enejb changed the title Boost: add awaiting-mod class to admin menu counter for standard WP styling Forms: add awaiting-mod class to Jetpack menu feedback unread counter badge Jun 30, 2026
@enejb enejb requested review from a team and simison June 30, 2026 01:01

@LiamSarsfield LiamSarsfield left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, and awaiting-mod is the right class for the sidebar bubble styling.

One thing worth sorting out before it merges: I think it collides with My Jetpack's red-bubble script. async-notification-bubble.ts queries .awaiting-mod inside #toplevel_page_jetpack .wp-menu-name, then rewrites or removes whatever it matches. Right now that's only its own bubble. Once our badge carries awaiting-mod, it matches ours too. On any admin screen other than My Jetpack, if the red-bubble transient has expired and the site has no MJ alerts, the count comes back 0 and the script calls bubble.remove(). Our unread counter then vanishes even when responses are unread. On a non-zero count it overwrites the class list and text instead, which drops jp-feedback-unread-counter and breaks the live count updates. Could you check with the My Jetpack folks about scoping their selector, or give our badge its own identifier instead of the shared class?

The tests also don't assert the new awaiting-mod output, so you could pull that arg back out and the suite would stay green. A one-line assertStringContainsString( 'awaiting-mod', ... ) on the nonzero menu test would lock it in.

Minor: is main-menu-only deliberate? The submenu badge doesn't get the class, so on the classic admin color schemes it'll still render flat.

@simison simison removed their request for review June 30, 2026 10:05
private function get_unread_count_badge_markup( $count, $unread_diff = null ) {
$attributes = "class='menu-counter jp-feedback-unread-counter count-" . (int) $count . "'";
private function get_unread_count_badge_markup( $count, $unread_diff = null, $extra_classes = '' ) {
$attributes = 'class=\'' . esc_attr( $extra_classes ) . ' menu-counter jp-feedback-unread-counter count-' . (int) $count . ' \'';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sprintf for clarity?

CGastrell
CGastrell previously approved these changes Jun 30, 2026

@CGastrell CGastrell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a nit, no blocker. LGTM! :shipit:

Address review feedback: use sprintf for the badge markup and trim the
class list so it no longer emits stray leading/trailing spaces.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin Page React-powered dashboard under the Jetpack menu [Feature] Contact Form [Package] Forms [Plugin] Boost A feature to speed up the site and improve performance. [Status] In Progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants