-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug fix: Add duotone class to lightbox experiment #51064
Bug fix: Add duotone class to lightbox experiment #51064
Conversation
I'm not sure if this change would break duotone in any way. |
It'd be great to ask someone involved in the duotone to check if it could cause issues somehow. Maybe @ajlende could help here (sorry for the ping if that's not the case)? |
It's definitely Alex who can give the best answer. I personally don't think you can narrow down the lookup to the Image block because block supports for duotone is not not only used with several other core blocks, but it also can be enabled by third-party blocks. Maybe all you need is to change this selector instead: gutenberg/packages/block-library/src/image/block.json Lines 111 to 113 in a3a63c1
|
5573115
to
78b3967
Compare
I rebased on #51089, which removes the extra
I've tried targeting the overlay markup using this approach and it hasn't worked. Will continue digging around. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The duotone hook adds the generated filter id as a class to the first element in the block content. gutenberg/lib/class-wp-duotone-gutenberg.php Lines 882 to 886 in 82f6d03
Then for the generated duotone CSS, it combines that filter id class with the duotone selector in block.json to apply the filter. gutenberg/lib/class-wp-duotone-gutenberg.php Lines 673 to 684 in 82f6d03
If you can get the filter id class on the lightbox wrapper and add the new lightbox selector to block.json, you should be able to get it to work. Let me know if you need any help :) |
Issue explanationI was reviewing this, and I believe we cannot get the filter id class in the lightbox container with the current implementation. The way I understood it:
<figure>
<img>
<div class="overlay">
<figure>
<img>
</figure>
</div>
</figure> The problem comes because the
For this reason, I believe we cannot follow this approach unless we modify the duotone filter, which may result in other issues. Potential solutionI was thinking about how to solve it, and maybe we can add the lightbox through a Apart from that, it would be a good first step to abstract the lightbox behavior of the image block, which is something worth exploring in the future. Any opinions on this approach? Would it make sense? If so, which is the best place to add this filter? |
Well, according to @mtias description in an issue. "Behaviors are meant to be reusable and composable interactive hooks that can be attached to blocks. " In my opinion, for this and future behaviors, a filter per behavior should be the way to go, as it would be the "easiest" hay to apply it to different blocks, rather than upgrading each block. Ideally, behaviors should not be hard coded in the block folder. Would be a good idea to have a proper package that could include all future behaviors? |
I wanted to echo what @c4rl0sbr4v0 said. It is a reasonable approach and aligns with how most of the block support features work today, including the duotone filter. You can use By the way, there is also a proposal discussed for a new |
I opened this pull request to move the behaviors to block supports, which should solve the problem with the duotone filter. Should we close this pull request @artemiomorales ? |
@SantosGuillamot Sounds good! Let's continue discussion in the new pull request. |
What?
Addresses #50973
Fixes a bug wherein duotone filters were not being applied to images with the lightbox behavior enabled
Why?
Basic functionality should work for image when the lightbox is activated
How?
Rather than putting the duotone class on the parent tag of the block in question, it loops through the elements and adds the class to the
<figure>
elements.Note: This uses @SantosGuillamot's suggested code from the following comment on the related issue.
Testing Instructions
Testing Instructions for Keyboard
N/A