Skip to content

Conversation

@simison
Copy link
Member

@simison simison commented Oct 8, 2025

Builds on top of:

Replaced previous PR:

Proposed changes:

  • Relies on count-0 class to hide badges instead of display:none
  • Updates counts optimistically before we get repliable count from the server

Pay attention to the counters in the sidebar:

Before

Screen.Recording.2025-10-10.at.16.50.01.mov

After

Screen.Recording.2025-10-10.at.16.51.49.mov

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

Testing instructions:

  • Have Jetpack notifications (e.g. disable Boost while you have paid complete plan)
  • Start with 0 notifications in Forms menu, but mark something as unread — count should appear and +1
  • Mark something as unread until badge goes away
  • Mark things as unread/read via actions in list, action in sidebar, and also by just opening a response
  • Ensure marking things as unread in trash/spam doesn't bump the counter up
  • When API call to mark things as read fails, it should return optimistic count back to what it was before

@simison simison changed the title Add/forms unread state optimistic updates2 Forms: optimistically update count in sidebar for read/unread actions (take two) Oct 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2025

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 add/forms-unread-state-optimistic-updates2 branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/forms-unread-state-optimistic-updates2

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

@simison simison added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. [Package] Forms labels Oct 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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!

@jp-launch-control
Copy link

jp-launch-control bot commented Oct 8, 2025

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/dashboard/inbox/utils.js 0/24 (0.00%) 0.00% 11 💔
projects/packages/forms/src/dashboard/inbox/dataviews/actions.js 0/151 (0.00%) 0.00% 8 💔
projects/packages/forms/src/dashboard/inbox/response.js 0/146 (0.00%) 0.00% 4 💔
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 428/1307 (32.75%) 0.03% -1 💚

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

*/
function updateBadge( element, count ) {
const oldClass = [ ...element.classList ].find( c => c.startsWith( 'count-' ) );
element.classList.replace( oldClass, `count-${ count }` );
Copy link
Member Author

Choose a reason for hiding this comment

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

Needs to use .add() here if oldClass wasn't found.

@simison simison added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Oct 9, 2025
enejb
enejb previously approved these changes Oct 9, 2025
Copy link
Member

@enejb enejb left a comment

Choose a reason for hiding this comment

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

This worked well for me in my testing. Nicely done.

@dhasilva dhasilva force-pushed the add/forms-unread-state-optimistic-updates2 branch from a2badae to 8419883 Compare October 10, 2025 14:12
Copy link
Contributor

@dhasilva dhasilva left a comment

Choose a reason for hiding this comment

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

Worked well for me. Nice!

@dhasilva dhasilva merged commit 0d12ba7 into trunk Oct 10, 2025
67 checks passed
@dhasilva dhasilva deleted the add/forms-unread-state-optimistic-updates2 branch October 10, 2025 14:36
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Contact Form I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Package] Forms [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants