-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Duplicate Icons on Chromium Based Browsers #235
Comments
The reproduction replicates the issue only because the SVG source files are identical... can you share an accurate reproduction? My best guess: the elements might not have a unique ID, so the references don't work? You can use the |
so sorry about that I think I didn't copy the code right while trying to replicate the issue, I recently initiated the switch to neovim from vscode.. . anyway I have updated the original code.. The SVGs are unique now, but the issue is still present. |
The problem is that SVGO optimizes SVG icons by replacing the id values of all elements with simpler ones. Its strategy is sequentially using Latin letters, starting from To solve the problem, you can use the prefixIds plugin, which will add a prefix and increment it each time: // astro.config.mjs
import { defineConfig } from 'astro/config';
import icon from 'astro-icon';
let prefixCounter = 0;
export default defineConfig({
integrations: [
icon({
iconDir: 'src/assets/icons',
svgoOptions: {
multipass: true,
plugins: [
{
name: 'cleanupIds', // optional
},
{
name: 'prefixIds',
params: {
delim: '',
prefix: () => prefixCounter++,
},
},
]
}
}),
],
}); @natemoo-re, it might be worth adding a note in the documentation or using the mentioned configuration as the default setting. |
one thing thou why doesn't it happen in firefox than? |
What version of
astro-icon
are you using?v1.1.0
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Chrome, Brave.. my guess on all the chromium based browsers
Describe the Bug
So I faced this weird issue the other day while using the plugin. Where If you use some Icons in together the icon will duplicate/clone itself idk what term to use.
Basically If you have 4 or 5 icons together some of them with show same icons instead of showing the one the svg is used for.. top bar section with multiple icons in chrome/brave
same section in firefox
using svg code directly works fine.
What's the expected result?
to see different icons, instead of one of them duplicating/cloning to others.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/duplicate-icons
The text was updated successfully, but these errors were encountered: