Content Guidelines: Fix AI button alignment and loading shimmer after Gutenberg changes - #52764
Conversation
|
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! 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. |
Code Coverage SummaryCoverage changed in 3 files.
|
| const isEmpty = ! useSectionHasDraft( slug ); | ||
| const generateLabel = __( 'Generate guidelines', 'jetpack' ); | ||
| const improveLabel = __( 'Improve guidelines', 'jetpack' ); | ||
| const generateLabel = isShortLabel |
There was a problem hiding this comment.
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.
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>
e876577 to
52fa77c
Compare
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>
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>



Fixes #
Proposed changes
Recent Gutenberg changes broke two things on the Guidelines page:
[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.ValidatedTextAreacontrol WordPress/gutenberg#81984 moved the DataForm textarea to@wordpress/ui. It no longer has the.components-textarea-controlclass, 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.Related product discussion/links
ValidatedTextAreacontrol WordPress/gutenberg#81984Does this pull request change what data or activity we track or use?
No.
Testing instructions
[Improve] [Clear] [Save], right-aligned. An empty section shows "Generate".[Dismiss] [Accept suggestion], right-aligned. Accept or dismiss it, and the generate button comes back in the same place.[Accept suggestion] [Dismiss]should stay left-aligned, as before.[Save] [Clear] [Improve guidelines],[Accept suggestion] [Dismiss]should be left-aligned, and the shimmer should still show.🤖 Generated with Claude Code