Issue Summary
When using a block reaction in context Drupal\block\Plugin\DisplayVariant\BlockPageVariant::build() is invoked. This function checks if the content or messages blocks are added and if they are not, it adds them. Normally this is desirable but when another context places these blocks in another region, the blocks are duplicated.
This is a very confusing issue to encounter as there will be no configuration placing the blocks anywhere and yet they cannot be removed.
Proposed Resolution
It may be preferable to limit blocks to only those actually defined in $this->blockRepository->getVisibleBlocksPerRegion.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | context-3073087-2.patch | 738 bytes | deaom |
Comments
Comment #2
deaom commentedThis is maybe not a best way to solve this issue, but maybe it points someone in the better direction. The messages gets added in the content area/block, so it's rendered regardless if it's not present in block layout. So I added a check to remove default messages block from content if the systems_messages_block is present (added via context).
Comment #3
paulocsThanks for the job @DeaOm.
I will have a look!
Comment #4
paulocsHello @all!
Can you please wright the steps to reproduce the issue?
I follow the steps below to reproduce it:
1) In a drupal fresh installation, download Context 8.x-4.x-dev.
2) Create a new Context with condition "Request Path" and Pages: .
3) Add in the new Context a block reaction and place the "Main page content" block on the sidebar second.
4) Go to front page and you see that the "Main page content" block is not displayed any more on the content region.
5) See that the "Main page content" block is displayed on sidebar second region.
Did I do the right steps? Please let me know.
Cheers, Paulo.
Comment #5
deaom commentedHi @paulocs, it's much simpler that what you've done. In the block layout messages block is added by default, in context add a block reaction and add a messages block to let's say sidebar. Then edit and re-save a node. You will see the status message displayed two times. Then you go to the block layout and remove the messages block, and again edit and re-save a node and again you will see the message displayed two times. At least that was my understanding.
Comment #6
paulocsI got it @DeaOm. Thanks for the explanation!
So I could reproduce the issue and patch #2 looks good to me as it verifies almost the same way as the BlockPageVariant.php from core verifies if the system message block is already placed or not in any region.
Set to RTBC.
Thanks @all.
Comment #8
paulocsFixed in dev branch.
Thanks :)