@box/blueprint-web 7.4.3 → 7.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib-esm/avatar/avatar.js +6 -1
- package/package.json +2 -2
package/lib-esm/avatar/avatar.js
CHANGED
|
@@ -62,8 +62,10 @@ const Avatar = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
62
62
|
...rest
|
|
63
63
|
} = props;
|
|
64
64
|
const [imageIsLoaded, setImageIsLoaded] = useState(false);
|
|
65
|
+
const [imageHasError, setImageHasError] = useState(false);
|
|
65
66
|
useEffect(() => {
|
|
66
67
|
setImageIsLoaded(false);
|
|
68
|
+
setImageHasError(false);
|
|
67
69
|
}, [src]);
|
|
68
70
|
const backgroundColor = color || colors[(colorIndex || 0) % colors.length];
|
|
69
71
|
const anonymousAvatarSize = anonymousAvatarSizes[size];
|
|
@@ -76,7 +78,7 @@ const Avatar = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
76
78
|
const imageIsLoading = !!src && !imageIsLoaded;
|
|
77
79
|
const shouldShowText = !anonymous && text && !imageIsLoaded;
|
|
78
80
|
const shouldShowAnonymousAvatar = anonymous || imageIsLoading && !text;
|
|
79
|
-
const shouldShowImage = !anonymous && src;
|
|
81
|
+
const shouldShowImage = !anonymous && src && !imageHasError;
|
|
80
82
|
const avatarContents = jsxs(Fragment, {
|
|
81
83
|
children: [shouldShowText && jsx("div", {
|
|
82
84
|
className: clsx(styles.text, styles[`length-${text.length}`]),
|
|
@@ -94,6 +96,9 @@ const Avatar = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
94
96
|
[styles.loading]: imageIsLoading
|
|
95
97
|
}),
|
|
96
98
|
loading: loading,
|
|
99
|
+
onError: () => {
|
|
100
|
+
setImageHasError(true);
|
|
101
|
+
},
|
|
97
102
|
onLoad: event => {
|
|
98
103
|
setImageIsLoaded(true);
|
|
99
104
|
onLoad?.(event);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.5",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@box/storybook-utils": "^0.2.1",
|
|
59
59
|
"react-stately": "^3.31.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "d498500e2ffb80ee401773086c239139b62c8e0d",
|
|
62
62
|
"module": "lib-esm/index.js",
|
|
63
63
|
"main": "lib-esm/index.js",
|
|
64
64
|
"exports": {
|