Skip to content

Commit e270b79

Browse files
fix(icon): clear stale glyph on name change; extract spinner color constant
Addresses review feedback: - When `name` changes on a mounted Icon to an icon that isn't cached yet, reset `icon` to undefined so the reserved fallback shows instead of the previous glyph while the dynamic import resolves. - Extract the fallback spinner color into a named LOADER_SPINNER_COLOR constant (mirrors the <Loader> default) instead of an inline magic hex. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b1df524 commit e270b79

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/lib/components/icon/Icon.component.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ type Props = {
7676
title?: string;
7777
};
7878

79+
// Mirrors the <Loader> default spinner color (see Loader.component.tsx) so the
80+
// fallback looks identical to a real Loader while the icon resolves.
81+
const LOADER_SPINNER_COLOR = '#A14FBF';
82+
7983
// The spinner shown while a cold icon loads. Sized in em so it scales with the
8084
// fa-${size} font-size of the fallback box, matching the glyph it stands in for —
8185
// unlike <Loader>, whose container forces a fixed px svg and resets font-size.
@@ -84,7 +88,7 @@ const FallbackSpinner = styled.span`
8488
svg {
8589
width: 1em;
8690
height: 1em;
87-
fill: #a14fbf;
91+
fill: ${LOADER_SPINNER_COLOR};
8892
}
8993
`;
9094

@@ -196,6 +200,10 @@ function NonWrappedIcon({
196200
return;
197201
}
198202

203+
// The name changed to an icon we haven't loaded yet: drop the previous glyph so the
204+
// reserved fallback shows instead of a stale icon while the dynamic import resolves.
205+
setIcon(undefined);
206+
199207
// Handle FontAwesome icons with dynamic import
200208
import(
201209
/* webpackExclude: /import\.macro\.js$/ */

0 commit comments

Comments
 (0)