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
I noticed this while testing Kibana Spaces. The following crashes the component:
<EuiAvatarname={' '}/>
The issue is caused by the code used to derive the avatar initials:
// A. Set to initials prop if exists (but trancate to 2 characters max unless length is supplied)if(initials){calculatedInitials=initials.substring(0,calculatedInitialsLength);}else{if(name.split(' ').length>1){// B. If there are any spaces in the name, set to first letter of each wordcalculatedInitials=name.match(/\b(\w)/g).join('').substring(0,calculatedInitialsLength);}else{// C. Set to the name's initials truncated based on calculated lengthcalculatedInitials=name.substring(0,calculatedInitialsLength);}}
This condition fails in step "B" above, because the regular expression /\b(\w)/g returns null for a string composed entirely of whitespace.
For this scenario, I'd expect the initials to be calculated as an empty string. Granted, this ins't a common scenario, and likely not one we want to encourage in a UI, but we should at least make sure the component doesn't crash.
The text was updated successfully, but these errors were encountered:
I noticed this while testing Kibana Spaces. The following crashes the component:
The issue is caused by the code used to derive the avatar initials:
This condition fails in step "B" above, because the regular expression
/\b(\w)/g
returnsnull
for a string composed entirely of whitespace.For this scenario, I'd expect the initials to be calculated as an empty string. Granted, this ins't a common scenario, and likely not one we want to encourage in a UI, but we should at least make sure the component doesn't crash.
The text was updated successfully, but these errors were encountered: