You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a custom block, with the media property set to an SVG with a transparent fill
Check the blocks tab, and
notice the fill is automatically set to currentColor
What is the expected behavior?
Fill should be transparent
What is the current behavior?
Fill inheritscurrentColor, which incorrectly renders the icon
Looks like fill is set to currentColor in a few places, but I think this line is the one causing troubles for the block panel.
When I toggle that off in Chrome's style tab, things appear to work:
.gjs-blocksvg {
fill: currentColor; // toggle this off
}
This is one of the flat icons bundled with react-icons. In the actual code, the svg is summoned with:
import{FiLink}from'react-icons/fi';import{renderToString}from'react-dom/server';consticon=renderToString(FiLink({size: '100%'}));console.log("icon",icon);// only used to grab the string for reproduction, otherwise passed to the `media` property
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
tonypapousek
changed the title
BUG: Unable to use transparent fill in Block svg
BUG: Unable to use transparent fill in Block media svg
Nov 20, 2024
I believe it depends on the specific SVG being used. If you check the other SVG icons, you'll notice they don't have a fill attribute (inline) on the main tag but rather on the child tags. By setting the fill="none" attribute on the two elements of this SVG, the icon should display properly. I hope this helps you resolve the issue!
@samex Specifying fill="none" did the trick, thanks! That'll deffo help get my custom stuff working more predictably.
Past that, I think the main pain point would be trying to use third-party SVGs (e.g. "react-icons") or wysiwyg output that doesn't explicitly set the fill attributes. With those use-cases in mind, I'll keep this bug open for now, unless the maintainers prefer it closed.
GrapesJS version
grapesjs@0.22.3
when this issue was filedWhat browser are you using?
Firefox 132, Chrome 131
Reproducible demo link
https://jsfiddle.net/x54f9v68/1/
Describe the bug
How to reproduce the bug?
media
property set to an SVG with a transparent fillnotice the fill is automatically set to
currentColor
What is the expected behavior?
![Screenshot 2024-11-20 at 10 38 00](https://private-user-images.githubusercontent.com/962327/388221705-4e1b546c-9b65-47ec-bafe-4354552d0f5b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MTE5NjAsIm5iZiI6MTczOTkxMTY2MCwicGF0aCI6Ii85NjIzMjcvMzg4MjIxNzA1LTRlMWI1NDZjLTliNjUtNDdlYy1iYWZlLTQzNTQ1NTJkMGY1Yi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxOFQyMDQ3NDBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jYzQ0N2YyYjA4ZWEwNmJhMWMxNjYyZDg3ZmZlMDBkNjRjYTFkZmQ3NDAzOGI2ODNiY2MzNWNiMDkxNjQ0Mzk3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.jXWtGYXPAaMYwqePU9IMyIOjz1Nn4n0yKAA-e8FLBwk)
Fill should be transparent
What is the current behavior?
Fill inherits
currentColor
, which incorrectly renders the iconLooks like
fill
is set tocurrentColor
in a few places, but I think this line is the one causing troubles for the block panel.When I toggle that off in Chrome's style tab, things appear to work:
This is one of the flat icons bundled with react-icons. In the actual code, the svg is summoned with:
Code of Conduct
The text was updated successfully, but these errors were encountered: