Fix admin notices and JITMs rendering inside page headers#47558
Fix admin notices and JITMs rendering inside page headers#47558
Conversation
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>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 2 files.
Full summary · PHP report · JS report Coverage check overridden by
I don't care about code coverage for this PR
|
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>
Code reviewNo 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 👎. |
|
Thanks for these changes. I found a couple of issue.
To enable it you need to add the following filter. |
CGastrell
left a comment
There was a problem hiding this comment.
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>


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:
GlobalNotices, JITM slot (#jp-admin-notices), andGlobalNoticeinto the tab panel'sbeforeContentprop so they render between the tab bar separator and tab content, not above the tabs.ConnectionErrorand the JITM slot out of theHeadercomponent and into the main admin page layout, afterAdminSectionHero. Also add the JITM slot to the pricing interstitial page branch.MockedSearchInterface(the hero section). Add auseEffectto relocate stray JITMs placed by JITM JS before React mounts, and a CSS fallback to hide them in#wpbody-content.Before / After
Other information
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:My Jetpack
wp-admin/admin.php?page=my-jetpack)Social
wp-admin/admin.php?page=jetpack-social)Search
wp-admin/admin.php?page=jetpack-search)