Skip to content

Fix admin notices and JITMs rendering inside page headers#47558

Open
vianasw wants to merge 6 commits intotrunkfrom
fix/admin-notices-inside-header
Open

Fix admin notices and JITMs rendering inside page headers#47558
vianasw wants to merge 6 commits intotrunkfrom
fix/admin-notices-inside-header

Conversation

@vianasw
Copy link
Contributor

@vianasw vianasw commented Mar 12, 2026

Fixes JETPACK-1420

Proposed changes

Admin notices and JITMs were rendering inside the page header (between the title and the page content) on several AdminPage-migrated pages. This PR moves them to the correct position:

  • My Jetpack: Move GlobalNotices, JITM slot (#jp-admin-notices), and GlobalNotice into the tab panel's beforeContent prop so they render between the tab bar separator and tab content, not above the tabs.
  • Social: Move ConnectionError and the JITM slot out of the Header component and into the main admin page layout, after AdminSectionHero. Also add the JITM slot to the pricing interstitial page branch.
  • Search: Move the JITM container after MockedSearchInterface (the hero section). Add a useEffect to relocate stray JITMs placed by JITM JS before React mounts, and a CSS fallback to hide them in #wpbody-content.

Before / After

Page Before After
My Jetpack Screenshot 2026-03-12 at 18 14 44 Screenshot 2026-03-12 at 18 11 58
Social Screenshot 2026-03-12 at 18 25 04 Screenshot 2026-03-12 at 16 25 01
Social (pricing) Screenshot 2026-03-12 at 18 26 32 Screenshot 2026-03-12 at 18 46 47
Search Screenshot 2026-03-12 at 18 15 42 Screenshot 2026-03-12 at 16 31 21

Other information

  • Generate changelog entries for this PR (using AI).

Related product discussion/links

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

No.

Testing instructions

Setup: Fake JITM

Add the following snippet to a mu-plugin (e.g. wp-content/mu-plugins/fake-jitm.php) to inject a test JITM on all Jetpack admin pages:

<?php
add_filter(
	'jetpack_jitm_received_envelopes',
	function ( $envelopes ) {
		$envelopes[] = (object) array(
			'id'                   => 'header-003-test',
			'feature_class'        => 'test',
			'content'              => (object) array(
				'message'     => 'HEADER-003 test JITM',
				'description' => 'This should appear below the header, not inside it.',
				'icon'        => '',
				'classes'     => '',
				'list'        => array(),
			),
			'CTA'                  => (object) array(
				'message'     => 'Learn more',
				'primary'     => true,
				'link'        => 'https://example.com',
				'newWindow'   => true,
				'ajax_action' => null,
			),
			'activate_module'      => null,
			'module_settings_link' => null,
			'is_dismissible'       => true,
			'url'                  => 'https://example.com',
			'jitm_stats_url'       => '',
			'message_path'         => '',
			'ttl'                  => 0,
			'expires'              => 0,
			'max_dismissal'        => 999,
			'template'             => 'default',
		);
		return $envelopes;
	}
);

My Jetpack

  1. Go to My Jetpack (wp-admin/admin.php?page=my-jetpack)
  2. Verify the JITM appears below the tab bar (Overview / Products / Help tabs), not between the page title and the tabs

Social

  1. Go to Jetpack Social (wp-admin/admin.php?page=jetpack-social)
  2. Verify the JITM appears below the "Write once, post everywhere" header section, not inside or above it

Search

  1. Go to Jetpack Search (wp-admin/admin.php?page=jetpack-search)
  2. Verify the JITM appears below the mocked search interface hero, not above or inside the header

vianasw and others added 2 commits March 12, 2026 10:44
Notices (bad-install, connection errors) and JITMs were rendering between
the page header and the tab bar. Move them into the tab content area via
a `beforeContent` prop on MyJetpackTabPanel, so they appear below the
tabs and separator line.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the JITM slot and connection error notices so they render below the
page header instead of inside it.

Social: Move #jp-admin-notices and ConnectionError from the Header
component into the main admin page, after AdminSectionHero.

Search: Move the JITM container after MockedSearchInterface. Add a
useEffect to relocate stray JITMs placed by JITM JS before React mounts,
and a CSS rule to hide them as a fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vianasw vianasw added the [Status] Needs Review This PR is ready for review. label Mar 12, 2026
@vianasw vianasw self-assigned this Mar 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2026

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/admin-notices-inside-header branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/admin-notices-inside-header

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 [Feature] Publicize Now Jetpack Social, auto-sharing [Package] My Jetpack [Package] Publicize [Package] Search Contains core Search functionality for Jetpack and Search plugins labels Mar 12, 2026
@github-actions
Copy link
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!

@jp-launch-control
Copy link

jp-launch-control bot commented Mar 12, 2026

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/publicize/_inc/components/admin-page/header/index.js 6/6 (100.00%) 0.00% 0 💚
projects/packages/publicize/_inc/components/admin-page/index.tsx 20/20 (100.00%) 0.00% 0 💚

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

vianasw and others added 3 commits March 12, 2026 16:20
Move the JITM-relocation useEffect below the isPageLoading declaration
to avoid a ReferenceError from the temporal dead zone. Variables
declared with const are not hoisted, so the useEffect callback and
deps array must come after the const.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When ConnectionError was moved from the Header component to the main
admin page, the CSS module reference styles['connection-error-col'] was
replaced with a bare string class name that had no matching CSS rule,
silently dropping the margin-top: 25px styling.

Move the .connection-error-col rule to the admin page's SCSS module and
restore the CSS module reference.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The JITM slot and ConnectionError only existed in the non-pricing
branch. When the pricing interstitial was shown, there was no
#jp-admin-notices element, so JITMs fell back to the PHP placeholder
above the header.

Add the JITM container inside the AdminSectionHero wrapping the pricing
page so it renders properly within the content flow on both paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vianasw vianasw added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Mar 13, 2026
@vianasw vianasw requested a review from a team March 13, 2026 09:41
@vianasw
Copy link
Contributor Author

vianasw commented Mar 15, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@enejb
Copy link
Member

enejb commented Mar 16, 2026

Thanks for these changes.

I found a couple of issue.

  1. Search on mobile viewport doesn't look quite right.

See
Screenshot 2026-03-16 at 8 18 54 AM

  1. the new newsletter admin page hasn't been updated. (Or maybe I am doing something wrong with building)

See
Screenshot 2026-03-16 at 8 18 29 AM

To enable it you need to add the following filter.

add_filter( 'jetpack_wp_admin_newsletter_settings_enabled', '__return_true' ); 

Copy link
Contributor

@CGastrell CGastrell left a comment

Choose a reason for hiding this comment

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

Code looks good and mostly works.

2 minor glitches:

  • JITM container on Search seems to overflow
  • Newsletters still show the JITM at the top

Both can be done either here or on a follow up. Other than that, looks good, let me know how you prefer to move forward.

…tion workarounds

Move #jp-admin-notices outside the isPageLoading conditional so it's always
in the DOM. JITM JS now always finds it via Path A (prepend into existing
element) instead of falling back to Path B (replace placeholder in
#wpbody-content). This removes the need for:

- useEffect that relocated stray JITM cards after React loaded
- CSS fallback hiding #wpbody-content > .jitm-card

Also conditionally renders the Container/Col around ConnectionError only
when there's actually a connection error, removing the always-present
empty Col that previously held the notices div.

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

Labels

[Feature] Publicize Now Jetpack Social, auto-sharing I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Package] My Jetpack [Package] Publicize [Package] Search Contains core Search functionality for Jetpack and Search plugins [Status] Needs Review This PR is ready for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants