Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#8 | Screenshot from 2020-06-30 14-20-50.png | 10.35 KB | paulocs |
#8 | Screenshot from 2020-06-30 14-21-17.png | 10.44 KB | paulocs |
#6 | block-classes-mix-3150394-6.patch | 1.3 KB | maticb |
#3 | mix-of-block-classes-between-blocks-3150394-2.patch | 748 bytes | MaxMendez |
Comments
Comment #2
MaxMendez CreditAttribution: MaxMendez commentedI found a solution so simple, here is the patch.
Comment #3
MaxMendez CreditAttribution: MaxMendez commentedComment #4
caspervoogt CreditAttribution: caspervoogt commentedThanks 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.
Comment #5
paulocsPatch #3 looks good to me.
Comment #6
maticb CreditAttribution: maticb commentedThe 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).
Comment #7
maticb CreditAttribution: maticb commentedComment #8
paulocsPatch #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!
Comment #10
paulocsFixed in dev branch!
Thanks @all!