Needs review
Project:
Drupal core
Version:
main
Component:
block.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Nov 2026 at 01:30 UTC
Updated:
19 Nov 2026 at 02:08 UTC
Jump to comment: Most recent
BlockPageVariant::build() marks the region as #sorted after building its blocks, even when hook_block_build_alter() has changed their weights. The blocks then render in their original order.
function example_block_build_alter(array &$build, BlockPluginInterface $block): void { if ($block->getPluginId() === 'user_login_block') { $build['#weight'] = -10; } }
/system/401 while logged out.
Make sure the region is only marked as #sorted if the final block weights are still in order.
Add a regression test.
Review.
Blocks now render in the order of their weights as changed by hook_block_build_alter:

None.
None.
None.
BlockPageVariant now respects changes to #weight made by hook_block_build_alter() when ordering blocks within a region.
| Comment | File | Size | Author |
|---|---|---|---|
| blockpagevariant_after.png | 29.61 KB | pancho | |
| blockpagevariant_before.png | 29.57 KB | pancho |
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
pancho