Skip to content

JITM: one slot component and one suppression helper for every dashboard - #52641

Merged
CGastrell merged 24 commits into
trunkfrom
add/jitm-slot-all-layouts
Sep 24, 2026
Merged

CGastrell merged 24 commits into
trunkfrom
add/jitm-slot-all-layouts

Conversation

@CGastrell

@CGastrell CGastrell commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes JETPACK-2756 in part

Proposed changes

wp-build's page template hides every direct child of #wpbody-content except the app root, so a JITM printed on admin_notices never shows. Five dashboards had each solved that separately, with five class names; eight showed no JITM at all. This replaces all of it with two shared pieces.

JitmSlot (js-packages/components) hosts #jp-admin-notices and puts the spacing on the card, not the container — so a slot that is always in the DOM and empty on most loads takes no space. It is a plain block-level sibling, which is what lets one component cover every layout: a dashboard chooses where, not how. A route that remounts the slot keeps its card: on unmount the slot parks the element, hidden, in <body>, and the next slot takes it back. It finds the element by id, because each wp-build route bundles its own copy of the component.

JITM::suppress_foreign_admin_notices() (packages/jitm) clears other plugins' notices from a screen while keeping ours. A full-screen product dashboard needs that protection — someone else's upsell will break a dual-pane layout — but remove_all_actions( 'admin_notices' ) also drops JITMs, which are a first-party channel, not someone else's notice. A screen that opted out through jetpack_display_jitms_on_screen has nothing registered to keep, so it stays silent. It matches callbacks by class rather than by object, because prepare_jitms() hooks the cached instance while get_instance() builds a fresh one.

The placement rule

The slot is the first child of whatever container owns that page's padding and column. In practice:

  • No tabs — sibling of the page header.
  • Tabs — first child of the page content, directly under the tab strip.

That is the position that costs no CSS. Anywhere else and the page immediately needs overrides to buy back the padding it lost, which is what every hand-rolled slot had been doing. The card inherits the page's own column rather than setting its own width.

Verified in a browser at 1440px on every dashboard — the card lands at the identical rect on all five tabbed ones:

Dashboard Card rect Slot's container
Search [184, 201, 1224, 76] under the tab strip
Social [184, 201, 1224, 76] under the tab strip
Forms [184, 201, 1224, 76] the DataViews header row
Protect [184, 201, 1232, 76] under the tab strip
Newsletter [184, 201, 1224, 76] under the tab strip
VideoPress [184, 201, 1224, 76] under the tab strip
Backup [184, 153, 1224, 76] under the header, no tabs
My Jetpack [276, 176, 1040, 76] its own Container/Col grid

My Jetpack is the deliberate exception: its page sets a narrower grid, and the slot inherits it. Note its card also sits 24px higher than before, because the old my-jetpack-jitm-card class carried a margin-top the shared style does not. Flagging rather than burying it — if that space should come back it belongs in the shared style, for everyone.

Three bugs this found

  1. Forms — card forced into a column. The layout mixin defines the scrollable page middle as .jp-admin-page__page > :not(:first-child):not(.jetpack-footer) and forces flex-direction: column on its children. Forms renders the slot as a direct child of the page, so the slot itself was claimed as the middle and the CTA dropped below the text (94px tall instead of 76px). Fixed by excluding .jp-jitm-slot from that rule, exactly as .jetpack-footer already is.
  2. Search — Overview only. Its slot lived inside Tabs.Panel value="overview", so Settings and AI Answers had no JITMs at all. It now renders once under the tab strip, the only place all three tabs share.
  3. Social — card 24px low. Its slot was the first child of the padded content container, so the container's padding stacked on the card's own margin. Moved outside it, and it now matches every other tabbed dashboard.

Newsletter and VideoPress: opt-outs removed

Both opted their modernized dashboard out of JITMs in #52471, because the page had no slot and JITM records a view when it fetches a message, not when it shows one — so fetching without a slot logs impressions for cards nobody sees. That was correct at the time. The slot exists now, so the opt-out and its two helper methods are gone from each (44 lines each).

These two are the clear half of that group: their legacy dashboards still render #jp-admin-notices and still show JITMs, so leaving them opted out means the same site owner gets a different experience depending on a modernization flag they cannot see.

Activity Log, Podcast and SEO stay opted out. They have no legacy dashboard with a slot, so they have never shown a JITM — restoring one there is a new product choice, not a repair. That is the single open question on JETPACK-2756, which argues the default should be "show them, and opt out on the record with a reason."

Scan

Untouched, and still on remove_all_actions( 'admin_notices' ) at packages/scan/src/class-jetpack-scan.php:248. suppress_foreign_admin_notices() is the drop-in replacement, but Scan's dashboard is its own gated port and changing it here would widen an already large diff. Called out so it is not mistaken for covered.

Boost

Checked in a browser, both its shells. Already correct, and deliberately untouched — no sense colliding with an active project for a refactor. Two optional follow-ups noted for its owner: swapping its three hand-rolled divs for JitmSlot, and the getting-started screen having no slot (a JITM there falls back to the classic wp-admin position and floats over the Boost header).

Shared layout mixin

Two changes beyond the slot.

Header padding on tabbed pages. The mixin no longer zeroes the header's bottom padding when a tab strip follows it. That spaced tabbed pages differently from the rest, so every page with the shared .jp-admin-page-tabs strip gets its bottom padding back: Social, Search, Protect, Newsletter, VideoPress, Scan, Podcast, SEO and Jetpack AI. Only the first five were checked in a browser.

.jp-admin-page-has-tabs, a style-free marker a page applies when its tab strip is not the shared .jp-admin-page-tabs. Forms' tab row is a DataViews toolbar that is already pinned and cannot take the strip's sticky/background styles, so it could not just adopt that class — and without it the mixin left its header border in place and the page drew two dividers under the header. Tabbed pages now render identically regardless of which tabs markup they use.

Related product discussion/links

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

No new tracking. Worth knowing for review: JITM records a view when a message is fetched, not when it is displayed. A dashboard that fetches without a slot logs views for cards nobody sees — which is exactly why the Newsletter and VideoPress opt-outs were right until this PR, and why removing them without adding the slot would have been wrong.

Testing instructions

Automated, all run on this branch:

  • jetpack test php packages/backup packages/newsletter packages/videopress — pass. packages/backup is 439, up from 434; the five new cases are in Admin_Notices_Suppression_Test.php. The Newsletter and VideoPress JITM tests are inverted rather than deleted, so they fail if someone re-adds an opt-out.
  • jetpack test js js-packages/components packages/forms packages/search packages/publicize packages/newsletter packages/videopress — pass. Three new cases cover JitmSlot.
  • pnpm run lint-changed, pnpm run lint-style <paths>, vendor/bin/phpcs and per-project pnpm run typecheck — clean.

Manual, on a local Docker site with a fixture mu-plugin answering the JITM fetch (so you are not waiting on wpcom targeting — use jetpack_jitm_received_envelopes on a connected site; jetpack_pre_connection_jitms only fires when disconnected):

  1. Open each of Backup, Forms, Search, Social, Protect, Newsletter, VideoPress, My Jetpack. The card appears under the tab strip, or under the header where there are no tabs.
  2. On Search, Social, Protect, Newsletter, VideoPress and Forms (Forms ↔ Responses), switch tabs. The card stays — it is not per-tab.
  3. Dismiss a card. No gap is left behind; the empty slot takes no vertical space.
  4. Register a third-party admin_notices callback in the same mu-plugin and open Backup. It must not appear, while the JITM still does.

The modernized Backup dashboard needs add_filter( 'rsm_jetpack_ui_modernization_backup', '__return_true' ) (or any proxied a12s request).

Screenshots

Screenshot 2026-09-23 at 16 19 46 Screenshot 2026-09-23 at 16 19 41 Screenshot 2026-09-23 at 16 19 34 Screenshot 2026-09-23 at 16 19 29 Screenshot 2026-09-23 at 16 19 23 Screenshot 2026-09-23 at 16 19 11 Screenshot 2026-09-23 at 16 18 56

@CGastrell CGastrell added the [Status] Needs Review This PR is ready for review. label Sep 22, 2026
@CGastrell CGastrell self-assigned this Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 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 or WordPress.com Site Helper), and enable the add/jitm-slot-all-layouts branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/jitm-slot-all-layouts
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/jitm-slot-all-layouts

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

@github-actions github-actions Bot added [JS Package] Components [Package] Backup [Package] Jitm [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests RNA labels Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

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


Backup 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.


Search 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.


Social 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.


Protect 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.


Videopress 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 Sep 22, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/jitm/src/class-jitm.php 74/163 (45.40%) -4.94% 16 💔
projects/packages/backup/src/class-jetpack-backup.php 432/514 (84.05%) -0.33% 2 ❤️‍🩹
projects/packages/videopress/src/class-admin-ui.php 110/318 (34.59%) -1.80% 0 💚
projects/packages/newsletter/src/class-settings.php 148/252 (58.73%) -1.04% -1 💚

2 files are newly checked for coverage.

File Coverage
projects/js-packages/components/components/jitm-slot/index.tsx 20/21 (95.24%) 💚
projects/js-packages/components/components/jitm-slot/types.ts 0/0 (—%) 🤷

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

@CGastrell
CGastrell force-pushed the add/jitm-slot-all-layouts branch from 525577d to bcdff20 Compare September 22, 2026 20:24
@CGastrell
CGastrell requested a review from a team as a code owner September 22, 2026 20:24
@CGastrell
CGastrell requested a review from a team as a code owner September 23, 2026 18:26
@github-actions github-actions Bot added [Package] Newsletter [Package] VideoPress [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. labels Sep 23, 2026
CGastrell and others added 11 commits September 23, 2026 16:22
Its slot carried a per-tab class modifier so the card could track the
Overview (720px) and Settings (660px) columns. A page-level slot cannot
track a tab-dependent column, which is what the modifier was working
around, so it takes the wider of the two and the modifier goes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reverses the previous rule. The slot now sits inside each dashboard's
content area, so it inherits that page's column instead of setting its
own width -- Social's width rules and per-tab modifier go away entirely,
and the shared style no longer fights the page.

Forms reaches it through DataViews' composition, between the header row
that holds the tabs and the table. Its slot is pinned flex: 0 0 auto
alongside the toolbar and footer, or the blanket grow rule stretches it.

Backup is unchanged: no tabs, already at the top of its content.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
It sat after the filters because both come from DataViewsHeaderRow. Moving
it inside that component puts it between the two, so the tabs stay the
anchor: header, tabs, message, filters, table.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Its slot lived inside the Overview tab panel, so Settings and AI Answers
had no JITMs at all. It now renders once under the tab strip, which is
also the only place all three tabs share.

That sits outside jp-search-dashboard-wrap, the page's only padded
container, so the card keeps a scoped inset. The old margin-zeroing goes:
the shared style owns spacing now.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The shared layout mixin dropped both the header's bottom border and its
bottom padding when a page has a tabs strip. The border is the right call
-- the strip's own hairline is the divider -- but removing the padding
spaced those pages differently from every other dashboard.

Affects the tabbed pages that include the mixin: Social, Search, My
Jetpack, Newsletter, Podcast, Activity Log. Forms is unaffected; its tabs
come from the DataViews header row, not `.jp-admin-page-tabs`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Forms' tab row is a DataViews toolbar, not `.jp-admin-page-tabs`, so the
mixin left its header border in place and the page drew two dividers.
Add `.jp-admin-page-has-tabs`, a style-free marker any page can declare,
and key the rule on either class.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Protect's slot was inside the hero, so it moved with the screen and
borrowed a class named after My Jetpack. It now sits under the tabs like
Search and Social.

Social's slot moves out of its padded content for the same reason: the
container's padding stacked on the card's own margin and pushed it 24px
lower than everywhere else. All four tabbed dashboards now land the card
at the same place.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both opted their modernized dashboard out because it had no slot, and a
fetched JITM records a view whether or not the page shows it. The slot
exists now, so render it and drop the opt-out.

These two are the clear half: their legacy dashboards still show JITMs,
so without this the same site owner gets a different experience
depending on a flag they cannot see. Activity Log, Podcast and SEO have
never shown one, so those stay opted out pending JETPACK-2756.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Six files repeated why a page outside a padded container owes the card a
gutter, in four phrasings. It belongs in the slot's own stylesheet, which
owns that contract; the consumers' selectors already say what they do.

Also drops a rotting pointer to three consumer sheets, the marker
explained twice in one file, and prose restating the code.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@CGastrell
CGastrell force-pushed the add/jitm-slot-all-layouts branch from 60cc2f9 to d0e43d4 Compare September 23, 2026 19:30
CGastrell and others added 3 commits September 23, 2026 16:42
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CGastrell

Copy link
Copy Markdown
Contributor Author

Forms: the card is lost on tab switch.

JitmSlot renders inside DataViewsHeaderRow, and each route stage renders its own copy of that row (forms, responses). Forms ↔ Responses unmounts the stage, so the card goes away with the old #jp-admin-notices. The JITM script fetches once per page load, so the card does not come back.

Fix: render the slot once, in a shell both routes share. Found by reading the code; not reproduced in a browser.

— Terminator

@CGastrell

Copy link
Copy Markdown
Contributor Author

Follow-up: move the card gutter into JitmSlot.

Six pages set the same gutter on the card themselves, var(--wpds-dimension-padding-2xl). Newsletter and Social set it through their own *-inset variables, which have the same value. Replace these six rules with one prop.

  1. js-packages/components/components/jitm-slot/

    • types.ts: add inset?: boolean. Doc: "The slot sits outside the page's padded container, so the card takes the page gutter."
    • index.tsx: when inset is set, add the class jp-jitm-slot--inset.
    • style.scss: after the .jp-jitm-slot block, add .jp-jitm-slot--inset .jitm-card { margin-inline: var(--wpds-dimension-padding-2xl); }. It has the same specificity as the base margin rule, so it must come after that rule. Delete the "owes the card margin-inline" comment, because the prop's doc replaces it.
    • test/index.test.tsx: add one case that inset adds the class. Confirm it fails when the class toggle is removed.
  2. Render <JitmSlot inset /> and delete the page's own rule on these pages:

    Page JSX Rule to delete
    Forms forms/src/dashboard/wp-build/components/dataviews-header-row/index.tsx forms/src/dashboard/wp-build/style.scss:79
    Search search/src/dashboard/components/pages/dashboard-page.jsx search/.../pages/dashboard-page.scss:127
    VideoPress videopress/src/dashboard/components/dashboard-layout/index.tsx .../dashboard-layout/style.scss:28
    Protect plugins/protect/src/js/components/protect-app/index.jsx plugins/protect/src/js/styles.module.scss:9
    Newsletter newsletter/_inc/components/newsletter-page.tsx newsletter-page.scss:29
    Social publicize/_inc/components/social-page.tsx social-page.scss:37

    Keep Forms' .jp-jitm-slot { flex: 0 0 auto }. Only the .jitm-card margin rule goes.

  3. Leave Backup and My Jetpack without inset. Their slot is already inside a padded body or a Col grid. Backup's margin-block-start: 0 override is on the other axis, so it stays.

  4. Forms: if the remount fix above moves the slot into a shared shell, put inset on the slot in its new place.

  5. Changelog: no new entries. The existing add-jitm-slot-all-layouts entries already cover the change.

Done when: at 1440px, the card rect on the six pages matches the table in the description (x=184, width=1224; 1232 on Protect). Backup and My Jetpack also stay unchanged, and no .jp-jitm-slot .jitm-card rule remains outside jitm-slot/style.scss: git grep -n "jp-jitm-slot .jitm-card" -- projects ':!*/jitm-slot/*' returns only Backup's override.

— Terminator

Forms renders the slot per route, so switching Forms and Responses
dropped the card, which the JITM script places once per page load.
The slot now parks #jp-admin-notices on unmount and the next slot
adopts it through the DOM, since each wp-build route bundles its own
copy of the component.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CGastrell

Copy link
Copy Markdown
Contributor Author

Fixed in 2942566. Forms has no shell that both routes share, so the fix is in JitmSlot. On unmount the slot parks #jp-admin-notices, hidden, in <body>, and the next slot adopts it by id. The lookup is by id because each wp-build route bundles its own copy of the component.

Checked in a browser: the card stays at the same rect through Forms → Responses → Forms. Search and Social are unchanged across tabs.

— Terminator

CGastrell and others added 2 commits September 23, 2026 18:48
Assert the untabbed branch in the Social test, so it checks what its
name says without reaching past Testing Library for the id. Guard the
ref instead of dereferencing it. Say in the changelog that the slot
keeps the message across route changes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Six pages set the same margin-inline on the card themselves. Move it
behind `inset`, so a page says it sits outside the padded container
instead of restating the value.

The inset rule shares the base rule's specificity, so it has to come
after it in the slot's own stylesheet. Backup and My Jetpack stay
without it: their slot is already inside a padded body or a Col grid.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@CGastrell

Copy link
Copy Markdown
Contributor Author

cc's

@LiamSarsfield since you're all about Boost page. The approach in Boost was considered for this ruling on the JITM, and it can stay like it is. If this is merged, then we might replace the ad hoc placement there with the new JitmSlot

@ederrengifo @keoshi while any design topics of the JITM card itself is not on the scope of this PR, placement is. There are some tweaks in place so the slot behaves nicely with all the layouts, let me know what you think or if we should follow up on something

@CGastrell
CGastrell merged commit e865d72 into trunk Sep 24, 2026
116 of 117 checks passed
@CGastrell
CGastrell deleted the add/jitm-slot-all-layouts branch September 24, 2026 17:42
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Contact Form [Feature] Publicize Now Jetpack Social, auto-sharing [JS Package] Base Styles [JS Package] Components [Package] Backup [Package] Forms [Package] Jitm [Package] My Jetpack [Package] Newsletter [Package] Publicize [Package] Search Contains core Search functionality for Jetpack and Search plugins [Package] VideoPress [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. RNA [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant