From bb687e0264a211266781fe52ffd1d254def27e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=86=E3=81=8D?= Date: Tue, 31 Dec 2024 15:22:57 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(avatar):=20Stop=20using=20ge?= =?UTF-8?q?tInitials=20in=20hashCode=20to=20allow=20different=20colors=20f?= =?UTF-8?q?or=20same=20initials=20with=20different=20names=20=F0=9F=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By removing `getInitials` from `hashCode`, the function now uses the full name to generate a hash. This ensures that even if two names produce the same initials, their colors will differ if their full names are different. --- .../components/Avatar/get-initials-color/get-initials-color.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@mantine/core/src/components/Avatar/get-initials-color/get-initials-color.ts b/packages/@mantine/core/src/components/Avatar/get-initials-color/get-initials-color.ts index 9f6f83efb59..3a8c38a0b2c 100644 --- a/packages/@mantine/core/src/components/Avatar/get-initials-color/get-initials-color.ts +++ b/packages/@mantine/core/src/components/Avatar/get-initials-color/get-initials-color.ts @@ -26,7 +26,7 @@ const defaultColors: MantineColor[] = [ ]; export function getInitialsColor(name: string, colors: MantineColor[] = defaultColors) { - const hash = hashCode(getInitials(name)); + const hash = hashCode(name); const index = Math.abs(hash) % colors.length; return colors[index]; }