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

Fix Avatar initials color hashing to use full name #7322

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

YukiKoNeko
Copy link
Contributor

Problem:
In the Avatar component, the getInitialsColor function was using only the initials of a name to generate a hash, which determined the color of the avatar. This led to the issue where different names with the same initials would receive the same color, even if the full names were different.

Solution:
The function now uses the full name to generate the hash. By removing the use of getInitials() inside the hashCode() call, each unique name will produce a unique hash, ensuring a unique color for each different name.

Details:

  • The hashCode() call is updated to process the entire name, not just the initials.
  • This change maintains the internal implementation without affecting the public API.
  • The behavior of the getInitialsColor function remains consistent, mapping the hash to an index in the colors array.

Impact:

  • Resolves the issue of same initials leading to same colors.
  • Enhances the distinguishability of avatars in user interfaces.

…colors for same initials with different names 🎨

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.
Updated test cases to reflect the new functionality
of `getInitialsColor`, ensuring accurate results
and preventing future test failures.
@rtivital rtivital merged commit 45d7c07 into mantinedev:master Jan 7, 2025
1 check passed
@rtivital
Copy link
Member

rtivital commented Jan 7, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants