Skip to content
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

Link Element: Color definitions should exclude Image block which can get linked element (e.g. within Gallery block) #53070

Open
porg opened this issue Jul 27, 2023 · 1 comment
Labels
[Package] Style Engine /packages/style-engine [Type] Bug An existing feature does not function as intended

Comments

@porg
Copy link

porg commented Jul 27, 2023

Followup Issue

<style id="wp-block-post-content-inline-css">
  .wp-block-post-content a:where(:not(.wp-element-button)){color: var(--wp--preset--color--link-plain);}
</style>
  • Now this yields a followup issue:

Reproduction

  1. Insert a native gallery with 3 images.
  2. Via the block inspector UI give all images a border-width: 1px.
    • The border-color and border-type hence inherit the defaults.
  3. Select the gallery block → Options → LINK TO: Media File.
    • This wraps each gallery <img> within an <a>.
    • Undesired outcome: The border of the images is now not black anymore but --wp--preset--color--link-plain (blue).
    • Fix on a CSS level: Extend the :not() selector to also exclude > .wp-block-image, so
      .wp-block-post-content a:where(:not(.wp-element-button, > .wp-block-image)){ ... }

Could someone please integrate that fix?

  • In the web browser DevTools of the Frontend view I could fix the CSS selector,
    • But I have now idea where in WordPress that fix needs to be integrated
      • In the Image block?
      • theme.json of TT3?
  • I hope a developer can use my hint and knows where to fix it adequately
@porg porg changed the title Element Link Color definitions should exclude Image block which can get linked element (e.g. within Gallery block) Link Element: Color definitions should exclude Image block which can get linked element (e.g. within Gallery block) Jul 27, 2023
@jordesign jordesign added [Type] Bug An existing feature does not function as intended [Package] Style Engine /packages/style-engine labels Jul 27, 2023
@porg
Copy link
Author

porg commented Jul 28, 2023

Addendum: Realized this detail only now

  • In the UI I had only explicitly set the image border-width: 1px
    • Therefore the border-style and border-color were just inherited.
    • And as the HTML hierarchy is: figure.wp-block-image → a → img if figure.wp-block-image gets no inline styles (strong specificity!) the deeper A element's color then gets inherited down to the even deeper IMG element, which eventually has the borders on it.
    • If in the UI you set an explicit color then figure.wp-block-image gets an element style attribute which prevails!
  • Updated issue description accordingly.

But still it is a bug

  • The .wp-block-image should definitely be excluded in that :not() lookahead selector.

For now I fixed it in my global.css (custom CSS file) with this:

.wp-block-post-content .wp-block-image a { color: unset; }

Maybe more specifically it could be:

.wp-block-post-content .wp-block-image.has-custom-border a { color: unset; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Style Engine /packages/style-engine [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants