When using drag and drop to reorder blocks, all blocks in a region (not only a specific block that was moved) may be assigned a new weight. This works okay when only core is in play and a single form is used to reorder all blocks, since reassigned weights retain their relative ordering.
When editing only a specific block visibility group, however, the fact that all of that group's blocks may be assigned a new weight means that, while their internal ordering is okay, their ordering relative to blocks placed globally or via other block visibility groups may have changed.
The problem arises from variations on the following steps:
The tabledrag behaviour leads to reassigned weights for all items in a group, not only the one that was dragged. Since they are not present on the form, blocks in different visibility groups retain their old weights, and so are out of order with the reordered ones.
A workaround is: whenever using any block layout screen, ensure "Show row weights" has been selected before making any changes, so that all block ordering is done manually through explicitly selecting block weights.
Alter the block filtering such that all blocks are always on the form, though only ones for the current visibility group (and, if desired, global blocks) are visible. Thus, all blocks in a given region are re-weighted and so retain their relative order.
For test coverage, we're drawing on the core test BookJavascriptTest::testBookOrdering()
for its use of JS drag and drop.
See the handbook page PHPUnit Javascript testing tutorial β for details on how to run JS tests.
Handling for the case that a given region has blocks but they're now all invisible. Need to change relevant class from 'region-populated' to 'region-empty'.
::getEntityIds()
may now be invoked multiple times and might need some caching.
Needs work
2.0
Code
The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.
The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.