I detected that the ContextReaction plugin for blocks concatenates the custom classes through blocks os a context that is rendering.

For example a context with 3 blocks:

block 1 has .green class
block 2 has .red class
block 3 has not classes

When the page is render the blocks are render

block 1 class .green class
block 2 class .green .red class
block 3 class .green .red class

This is related with the code added base on https://www.drupal.org/project/context/issues/2979536

Note: i think the issue https://www.drupal.org/project/context/issues/2979536 it could be closed

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MaxMendez created an issue. See original summary.

MaxMendez’s picture

I found a solution so simple, here is the patch.

MaxMendez’s picture

FileSize
748 bytes
caspervoogt’s picture

Thanks Max; good catch. I ran into this too and immediately suspected Context, which brought me here. mix-of-block-classes-between-blocks-3150394-2.patch works for me.

paulocs’s picture

Status: Active » Reviewed & tested by the community

Patch #3 looks good to me.

maticb’s picture

The patch is fine, but the code could be improved, array can be only a declaration, it doesn't have to be in 2 lines, also the array push makes no sense since it's only 1 item, always.

I've added the above and another slight optimization (skip array merge if it doesn't have a custom class).

maticb’s picture

Status: Reviewed & tested by the community » Needs review
paulocs’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
10.44 KB
10.35 KB

Patch #6 looks good for me.
I tested with two different blocks and they are not mixing each other.
I tested with empty classes values and they are working as well.

If you see the images, I added the class "test1" in one block and "test2" in another block.

Thanks!

  • paulocs committed d354895 on 8.x-4.x authored by maticb
    Issue #3150394 by MaxMendez, maticb, paulocs, caspervoogt: Mix of block...
paulocs’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in dev branch!
Thanks @all!

Status: Fixed » Closed (fixed)

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