From 908ec123de3089b219cfe41092c52558ae98e9f1 Mon Sep 17 00:00:00 2001 From: Johannes Munker <56400587+jomunker@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:26:20 +0200 Subject: [PATCH] Use unique ids for `CometColor` component so that there are no SVG scoping problems (#2529) Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com> --- packages/admin/admin-icons/package.json | 5 +++++ packages/admin/admin-icons/src/CometColor.tsx | 20 ++++++++++++++----- pnpm-lock.yaml | 16 ++++++++++++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/packages/admin/admin-icons/package.json b/packages/admin/admin-icons/package.json index 4c85860890..141fa62780 100644 --- a/packages/admin/admin-icons/package.json +++ b/packages/admin/admin-icons/package.json @@ -22,6 +22,10 @@ "start:babel": "npx babel ./src -x \".ts,.tsx\" -d lib -w", "start:types": "tsc --project ./tsconfig.json --emitDeclarationOnly --watch --preserveWatchOutput" }, + "dependencies": { + "use-constant": "^1.0.0", + "uuid": "^9.0.0" + }, "devDependencies": { "@babel/cli": "^7.17.6", "@babel/core": "^7.20.12", @@ -32,6 +36,7 @@ "@types/node": "^18.0.0", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", + "@types/uuid": "^10.0.0", "cli-progress": "^3.8.2", "eslint": "^8.0.0", "fast-xml-parser": "^4.2.5", diff --git a/packages/admin/admin-icons/src/CometColor.tsx b/packages/admin/admin-icons/src/CometColor.tsx index 11b8f1ee8d..95eb36c016 100644 --- a/packages/admin/admin-icons/src/CometColor.tsx +++ b/packages/admin/admin-icons/src/CometColor.tsx @@ -1,23 +1,33 @@ import { SvgIcon, SvgIconProps } from "@mui/material"; +import useConstant from "use-constant"; +import { v4 as uuidv4 } from "uuid"; + +function getUniqueId() { + return `comet-icon-${uuidv4()}`; +} export default function Comet(props: SvgIconProps) { + const uniqueIdA = useConstant(getUniqueId); + const uniqueIdB = useConstant(getUniqueId); + const uniqueIdC = useConstant(getUniqueId); + return ( - + - - + + - +