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.

CommentFileSizeAuthor
#2 context-3073087-2.patch738 bytesdeaom

Comments

malcolm_p created an issue. See original summary.

deaom’s picture

Status: Active » Needs review
StatusFileSize
new738 bytes

This 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).

paulocs’s picture

Thanks for the job @DeaOm.
I will have a look!

paulocs’s picture

Hello @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.

deaom’s picture

Hi @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.

paulocs’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

  • paulocs committed c5ad827 on 8.x-4.x authored by DeaOm
    Issue #3073087 by DeaOm, paulocs, malcolm_p: Messages block can be...
paulocs’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in dev branch.

Thanks :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.