From 2bec11b897a7bad59f793cb36da741646886cfcf Mon Sep 17 00:00:00 2001 From: Larry Gregory Date: Wed, 3 Oct 2018 10:47:42 -0400 Subject: [PATCH] Allow avatar name to be composed entirely of whitespace (#1231) * allow avatar name to be composed entirely of whitespace * changelog --- CHANGELOG.md | 1 + .../avatar/__snapshots__/avatar.test.js.snap | 16 ++++++++++++++++ src/components/avatar/avatar.js | 2 +- src/components/avatar/avatar.test.js | 12 ++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 135559581be..035ad04903e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ **Bug fixes** - Fix EuiToolTip to show tooltips on disabled elements ([#1222](https://github.com/elastic/eui/pull/1222)) +- Fix EuiAvatar when name is composed entirely of whitespace ([#1231](https://github.com/elastic/eui/pull/1231)) ## [`4.3.0`](https://github.com/elastic/eui/tree/v4.3.0) diff --git a/src/components/avatar/__snapshots__/avatar.test.js.snap b/src/components/avatar/__snapshots__/avatar.test.js.snap index 3ce164e6bf7..dab54766170 100644 --- a/src/components/avatar/__snapshots__/avatar.test.js.snap +++ b/src/components/avatar/__snapshots__/avatar.test.js.snap @@ -1,5 +1,21 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`EuiAvatar allows a name composed entirely of whitespace 1`] = ` +
+ +
+`; + exports[`EuiAvatar is rendered 1`] = `
1) { + if (name.trim() && name.split(' ').length > 1) { // B. If there are any spaces in the name, set to first letter of each word calculatedInitials = name.match(/\b(\w)/g).join('').substring(0, calculatedInitialsLength); } else { diff --git a/src/components/avatar/avatar.test.js b/src/components/avatar/avatar.test.js index abbcc53480f..5c92a7e0205 100644 --- a/src/components/avatar/avatar.test.js +++ b/src/components/avatar/avatar.test.js @@ -17,6 +17,18 @@ describe('EuiAvatar', () => { .toMatchSnapshot(); }); + test('allows a name composed entirely of whitespace', () => { + const component = render( + + ); + + expect(component) + .toMatchSnapshot(); + }); + describe('props', () => { describe('imageUrl', () => { it('is rendered', () => {