@7shifts/sous-chef 4.10.0 → 4.10.3

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.
@@ -20572,7 +20572,16 @@ const Avatar = ({
20572
20572
  isVisible,
20573
20573
  elementRef
20574
20574
  } = useIsVisibleInViewPort();
20575
- const url = isVisible ? urlProp : undefined;
20575
+ // Latch visibility: unloading the image when the avatar leaves the
20576
+ // viewport makes it flash the fallback colors when it re-enters (e.g.
20577
+ // inside a scroll-away nav bar).
20578
+ const [hasBeenVisible, setHasBeenVisible] = useState(false);
20579
+ useEffect(() => {
20580
+ if (isVisible && !hasBeenVisible) {
20581
+ setHasBeenVisible(true);
20582
+ }
20583
+ }, [isVisible, hasBeenVisible]);
20584
+ const url = hasBeenVisible ? urlProp : undefined;
20576
20585
  const [showIconInsteadOfImage, setShowIconInsteadOfImage] = useState(false);
20577
20586
  const [defaultProfilePictureColors] = useState(() => PROFILE_IMAGES[Math.floor(Math.random() * PROFILE_IMAGES.length)]);
20578
20587
  // If passing an url we are defaulting to a lighter grey while the image loads