Content Guidelines AI: update injection selectors for latest Gutenberg#49155
Conversation
| Are you an Automattician? The PR will need to be tested on WordPress.com. This comment will be updated with testing instructions as soon the build is complete. |
|
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 🤖 🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so: Follow this PR Review Process:
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:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
188a245 to
002503e
Compare
The Gutenberg Guidelines page markup changed in two ways that broke the AI UI injection (silently — the bundle loaded with no console error but nothing rendered): - content-guidelines__* classes were renamed to guidelines__*. - The accordion was refactored to CollapsibleCard (hashed CSS-module classes) and the per-section element id was removed. Update lib/inject.js to anchor on stable selectors: - Per-section badge/actions/button now key off the new `data-slug` attribute on `.guidelines__list-item`, plus semantic anchors (form, submit button) within each section. - Banner / upgrade notice use the renamed `.guidelines__list`. - The header "Suggest all" button moves to the top of `.guidelines__content` (the wp-admin Page header renders no actions slot since the page passes no `actions`). The block-guideline modal selectors are unchanged. Depends on the Gutenberg `data-slug` hook. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
002503e to
190a217
Compare
Proposed changes
Stacked on top of #47959.
The Gutenberg Guidelines page markup changed in ways that silently broke the Content Guidelines AI UI injection — the JS bundle loads (HTTP 200, no console error) but zero components render, because every DOM anchor the injector looks for no longer exists:
content-guidelines__*classes were renamed toguidelines__*(Gutenberg #77223).CollapsibleCard(Gutenberg #77903), which emits hashed CSS-module class names and removed the per-section elementid.header-actionsslot because the Guidelines page passes noactionsto<Page>.This PR updates
_inc/content-guidelines-ai/lib/inject.jsto anchor on stable selectors:data-slugattribute on.guidelines__list-item, then use semantic anchors within the section (form, thetype="submit"button's HStack, the form's top VStack)..guidelines__list..guidelines__content(above the list), since there is no header-actions slot to target.Dependency
Requires the Gutenberg-side hook: WordPress/gutenberg#78676 (
data-slugon the guideline list items). Until that ships in the bundled Gutenberg, the per-section injections will no-op.Testing instructions
gutenberg-guidelinesexperiment.wp-admin/options-general.php?page=guidelines-wp-admin&enable_ai_generation=true.Verification done
data-slugattribute simulated), and a marker-insertion test placed every component at the correct spot.@automattic/jetpack-ai-client/jetpack-componentsbuild artifacts); CI/sandbox builds it normally.