Skip to content

Content Guidelines: Fix AI button alignment and loading shimmer after Gutenberg changes - #52764

Merged
aagam-shah merged 14 commits into
trunkfrom
fix/content-guidelines-ai-section-button-order
Sep 28, 2026
Merged

aagam-shah merged 14 commits into
trunkfrom
fix/content-guidelines-ai-section-button-order

Conversation

@aagam-shah

@aagam-shah aagam-shah commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #

Proposed changes

Recent Gutenberg changes broke two things on the Guidelines page:

  • Button order. Fix: Content Guidelines: UX/UI Accessibility issues WordPress/gutenberg#80306 changed the section buttons from left-aligned [Save] [Clear] to right-aligned [Clear] [Save]. Our Generate/Improve button now shows to the right of Save. When Save is last in the row, we now add our button first. Otherwise, we add it last as before. This works on old and new Gutenberg.
  • Loading shimmer. UI: Add ValidatedTextArea control WordPress/gutenberg#81984 moved the DataForm textarea to @wordpress/ui. It no longer has the .components-textarea-control class, and a wrapper draws the border, so the shimmer and green border stopped showing. We now also target the textarea's wrapper. The old selector still works for older Gutenberg and the block modal.
  • Diff position. Gutenberg 24.0 shows the field label, but we hid the whole DataForm while a suggestion is active, so the diff jumped up. Now the diff sits after the DataForm and only the textarea box is hidden. The diff also matches the new textarea's height, line height, and padding.
  • On newer Gutenberg, shorten the section button to "Generate" / "Improve" to match the bare "Clear" and "Save" next to it. Older Gutenberg keeps "Generate guidelines" / "Improve guidelines".
  • In sections, align Accept suggestion and Dismiss like the Save/Clear row: right-aligned with Accept last on new Gutenberg, left-aligned with Accept first on older Gutenberg. The block guideline modal keeps its left-aligned row.

Related product discussion/links

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

No.

Testing instructions

  • Sync this branch to a site with Jetpack AI and the latest Gutenberg. Go to Settings → Guidelines.
  • Each section should show [Improve] [Clear] [Save], right-aligned. An empty section shows "Generate".
  • Click it. While it loads, the textarea should have a green border and a moving shimmer.
  • When the suggestion shows, the field label should stay, and the diff should sit exactly where the textarea was.
  • The row should be [Dismiss] [Accept suggestion], right-aligned. Accept or dismiss it, and the generate button comes back in the same place.
  • Open "Add block guideline", pick a block, and generate. The shimmer should show, and [Accept suggestion] [Dismiss] should stay left-aligned, as before.
  • On a site with older Gutenberg, the section row should stay [Save] [Clear] [Improve guidelines], [Accept suggestion] [Dismiss] should be left-aligned, and the shimmer should still show.

🤖 Generated with Claude Code

@aagam-shah aagam-shah added [Status] In Progress [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Bug labels Sep 24, 2026
@aagam-shah aagam-shah self-assigned this Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 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), and enable the fix/content-guidelines-ai-section-button-order branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/content-guidelines-ai-section-button-order

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

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.

@jp-launch-control

jp-launch-control Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/_inc/content-guidelines-ai/lib/inject.js 0/119 (0.00%) 0.00% 2 ❤️‍🩹
projects/plugins/jetpack/_inc/content-guidelines-ai/components/suggestion-actions.jsx 34/35 (97.14%) 0.27% 0 💚
projects/plugins/jetpack/_inc/content-guidelines-ai/lib/dom.js 13/13 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

@aagam-shah aagam-shah changed the title Content Guidelines: Keep Save at the edge of the section button row Content Guidelines: Fix AI button alignment and loading shimmer after Gutenberg changes Sep 25, 2026
const isEmpty = ! useSectionHasDraft( slug );
const generateLabel = __( 'Generate guidelines', 'jetpack' );
const improveLabel = __( 'Improve guidelines', 'jetpack' );
const generateLabel = isShortLabel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this is actually worth doing? I'd keep "Generate guidelines" / "Improve guidelines" on all versions. It's the one AI action in the row, so the longer label is clearer, and it avoids the label changing depending on the Gutenberg version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is how weird it looks:

Image

aagam-shah and others added 11 commits September 28, 2026 14:32
Gutenberg now right-aligns the section row as [Clear][Save]. Insert the
Generate/Improve button first in that layout so Save stays rightmost, and
keep appending it on older Gutenberg's left-aligned [Save][Clear] row.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Match Gutenberg's action rows: right-aligned with the primary button
last, in both the section panel and the block guideline modal.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Gutenberg now renders DataForm's textarea with @wordpress/ui, which drops
the .components-textarea-control class and draws the border on a wrapper.
Target the textarea's wrapper too, so the shimmer and green border show.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Gutenberg 24.0 shows the section field label, and 23.9 moved the textarea
to @wordpress/ui. Place the diff after the DataForm and hide only the
textarea box, measure the bordered wrapper, and match its line height
and padding.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Inject the suggestion container right after the textarea box, inside the
field, and hide the box before it. This removes the extra gap under the
label and works the same on old and new Gutenberg.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
offsetHeight rounds 94.58px up to 95px. Use getBoundingClientRect so the
diff matches the bordered box exactly.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Before 24.0, Gutenberg left-aligns the section's [Save][Clear] row. Match
it when Save is the first button in that row.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The modal's Generate button is left-aligned, and Accept/Dismiss replace it
in the same row, so keep that row as it was.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Match the section's Save/Clear row: older Gutenberg left-aligns
[Save][Clear], so show [Accept suggestion][Dismiss] left-aligned there.
Set the order in the markup so tab order matches what users see.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Newer Gutenberg's section row has bare "Clear" and "Save" buttons, so
label ours "Generate" or "Improve" there. Older Gutenberg keeps the full
labels.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Use plain __() so the short labels share the translations Jetpack
already has for other AI buttons.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@aagam-shah
aagam-shah force-pushed the fix/content-guidelines-ai-section-button-order branch from e876577 to 52fa77c Compare September 28, 2026 09:15
aagam-shah and others added 2 commits September 28, 2026 15:14
Terser folded the two __() calls in each label ternary into one call with
a conditional msgid, which the i18n check rejects. Add a dummy argument
to one call so the calls differ.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Check the Save row once in inject.js and pass it to both components, so
  Accept/Dismiss order is right on first render and uses the same check.
- Find the textarea box by class, the same way the CSS does.
- Wrap :has() selectors in :is(), so browsers without :has() keep the
  rest of each selector list (the minifier merges rules into lists).
- Apply the diff text override only to the @wordpress/ui textarea.

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

This comment was marked as outdated.

The @wordpress/ui textarea uses 16px text below 600px to avoid mobile
zoom. Do the same in the diff, and shorten the shimmer comment.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The compatibility logic matches the referenced Gutenberg DOM changes and is covered by targeted tests.

Review effort: Balanced
Findings: None

Resolved since last review (3)

@aagam-shah
aagam-shah marked this pull request as ready for review September 28, 2026 12:52
@aagam-shah
aagam-shah merged commit 577205a into trunk Sep 28, 2026
86 checks passed
@aagam-shah
aagam-shah deleted the fix/content-guidelines-ai-section-button-order branch September 28, 2026 13:02
@github-actions github-actions Bot added this to the jetpack/16.3 milestone Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [Type] Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants