Post Date: Migrate to textAlign block support#75856
Post Date: Migrate to textAlign block support#75856t-hamano merged 4 commits intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| @@ -129,13 +122,6 @@ export default function PostDateEdit( { | |||
| { ( blockEditingMode === 'default' || | |||
There was a problem hiding this comment.
{ ( blockEditingMode === 'default' || ! isDescendentOfQueryLoop ) &&
activeBlockVariationName !== 'post-date-modified' &&
( ! isDescendentOfQueryLoop || ! activeBlockVariationName ) && (
<BlockControls group="block">
<ToolbarGroup>
</ToolbarGroup>
</BlockControls>
) }All of the conditional checks here should be able to be consolidated.
| <!-- wp:post-date {"metadata":{"bindings":{"datetime":{"source":"core/post-data","args":{"field":"date"}}}}} /--> | ||
|
|
||
| <!-- wp:post-date {"metadata":{"bindings":{"datetime":{"source":"core/post-data","args":{"field":"date"}}}}} /--> | ||
|
|
||
| <!-- wp:post-date {"metadata":{"bindings":{"datetime":{"source":"core/post-data","args":{"field":"date"}}}}} /--> |
There was a problem hiding this comment.
This doesn't seem to be the expected result. The text alignment seems to be discarded.
There was a problem hiding this comment.
The v2 deprecation migration was unintentionally overwriting v4's correctly migrated textAlign attribute back to the top level, because both were triggering sequentially on the original block attributes.
I fixed this by updating v2's isEligible check to explicitly exclude blocks that have textAlign, allowing v4 to handle them correctly. The fixtures have been regenerated with the proper output!
There was a problem hiding this comment.
I fixed this by updating
v2's isEligible check to explicitly exclude blocks that havetextAlign
The v2 deprecation is a necessary step to migrate block attributes to Block Bindings. Adding exclusion rules will cause unintended problems. Please try the following:
- Open the code editor and insert the following HTML:
<!-- wp:post-date {"displayType":"modified"} /-->
<!-- wp:post-date {"displayType":"modified", "textAlign":"right"} /-->- Back to the Visual editor, and back to the Code editor again.
- Unintended migration is occurring in a block that has textAlign.
✅
<!-- wp:post-date {"metadata":{"bindings":{"datetime":{"source":"core/post-data","args":{"field":"modified"}}}},"className":"wp-block-post-date__modified-date"} /-->❌
<!-- wp:post-date {"datetime":"2026-03-16T10:14:11.214Z","style":{"typography":{"textAlign":"right"}}} /-->There was a problem hiding this comment.
The solution is probably to add migrate: migrateTextAlign to v1, v2, and v3 as well. See #74383 (comment)
Combine nested conditionals into a single check to avoid empty BlockControls wrapper components. Co-Authored-By: Claude Opus 4.6 <[email protected]>
What?
Part of #60763
Migrates the Post Date block to use the
textAlignblock support instead of a customtextAlignattribute. As a consequence, it also enables global styles support fortextAlignon the Post Date block.Why?
The Post Date block currently implements its own text alignment logic with a custom
textAlignattribute and a manualAlignmentControlin the toolbar, duplicating code that should be handled by the centralizedtextAlignblock support.This migration reduces code duplication and consolidates alignment handling across blocks.
How?
Replaces the custom logic with the block supports, adds deprecation and fixes transforms.
Testing Instructions
Post Dateblock and test text alignment (left, center, right).Post Dateblocks that have alignment set.