Skip to content

[fix] Icon: a glyph given as name renders and warns, instead of crashing - #12374

Closed
josephfarina wants to merge 4 commits into
mainfrom
josephfarina/rl-icon-name-alias
Closed

josephfarina wants to merge 4 commits into
mainfrom
josephfarina/rl-icon-name-alias

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Record change (component:Icon): FR1 now says that without icon, a name that is a key string or an icon component is the glyph source; it does not reach the DOM, and a development warning names icon. Its Basis names the owner decision, and the verification map lists the test suite. Types are unchanged.

Proof: Icon.test.tsx covers a key, a plain component, forwardRef and memo components given as name, name beside icon, and icon without a warning. Icon + IconButton: 170/170 pass with CI=1. Strict eslint, prettier and tsc --noEmit are clean. Gate result: on a frozen set of agent-written pages, 16 of 19 that crashed on <Icon name=…> now render (3 fully work). Every page that worked before still works, with no new console errors in light, dark or 390 px phone width. No visual change for a call with icon, so there are no before/after pictures.


User impact

<Icon name="check" /> fails the whole render with React's "Element type is invalid … got: undefined". Several popular icon libraries call the glyph prop name. TypeScript reports the missing icon, but the crash reaches code that is not type-checked: JavaScript callers and generated pages rendered without a type check. Generated pages hit this often; in a corpus of agent-written pages it was the second most common render crash.

Problem and solution fit

  • The crash happens because without icon, Icon takes the component-mode branch and renders undefined as the element type.
  • It harms the task because one icon takes down the whole page, and the error names no component or prop.
  • After this change, a call without icon reads name as the glyph when it is one (a semantic key, namespaced key or icon component, including memo, forwardRef and lazy components), keeps that name off the DOM, and a development warning says to pass icon. A call with icon is unchanged.

Expected behavior and authority

component:Icon FR1 (Icon presents one glyph from the supplied source); the record's FR1 now states the name fallback. Types are unchanged: icon stays the documented, required prop.

Smallest restoration

One helper (readGlyph) and one useDevWarning call in Icon.tsx. No type, default or styling change.

Evidence

  • Reproduction before the change: <Icon name="check" /> throws "Element type is invalid".
  • Result after the change: it renders the check glyph without a name attribute, and warns once in development.
  • Representative unchanged path: <Icon icon="check" /> renders and does not warn.
  • Regression test: five new cases in Icon.test.tsx (registry key as name, component as name, forwardRef and memo components as name, name passed through untouched when icon is given, icon given without a warning).
  • Agent-written pages: of 19 that crashed on <Icon name=…>, 16 now render; pages that worked before are unchanged. The other 3 stop at an unrelated component error. No page that rendered before fails now.

Scope

Components: Icon

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

CI=1 vitest run packages/core/src/Icon packages/core/src/IconButton (170 passed); strict eslint (ASTRYX_STRICT_LINT=1), prettier and tsc --noEmit on the package.

Writing rubric results

R1 narration: none; FR1 states current behavior in the present tense.
R2 research: none in the record; corpus numbers are only in this description.
R3 evidence: FR1's Basis names the owner decision and current tests; the verification map gains an FR1 row naming the test suite, not a change.
R4 rejected alternatives: none recorded.
R5 change references: none.
R6 open questions: none.
R7 project status: none.

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 17, 2026 8:48pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 9:00 PM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 2d27454

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about the new name fallback, and on one fix to the description.

The new component:Icon FR1 sentence (without icon, a name prop is the glyph source, stays off the DOM, and a development warning names icon) adds a requirement that no current spec states, so an engineering owner has to accept or reject it. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request; as an engineering owner, the author may do so.

  • The description says TypeScript does not flag <Icon name="check" />, but tsc reports TS2741 ("Property 'icon' is missing") because icon is required, so please say instead that the crash reaches code that is not type-checked.

Non-blocking: the "prefers icon" test passes no name, so adding name there would prove that name still reaches the element beside icon; the inline comments have two smaller notes.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim (title): a glyph given as name renders and warns instead of crashing: verified; both new name tests fail on the base with "Element type is invalid" and pass on the head.
  • Claim (changeset): Icon renders a name glyph, warns in development to use icon, and keeps name off the DOM: verified by the new tests and a rendered check.
  • Claim (description): without icon, Icon renders undefined as the element type and the whole render fails: verified on the base.
  • Claim (description): TypeScript does not flag the call: false; TS2741.
  • Claim (description): a call with icon is unchanged and types are unchanged: verified; name beside icon still reaches the element, and the public API surface shows no change.
  • Claim (description): one helper and one development-warning call, with no type, default or styling change: verified.
  • Claim (description): 16 of 19 crashing generated pages now render: not verifiable from the repository.
  • Claim (description): the Icon test suites pass with 168 tests: verified.
  • File packages/core/src/Icon/Icon.tsx: clear, with one comment suggestion.
  • File packages/core/src/Icon/Icon.test.tsx: one non-blocking test gap.
  • File packages/core/src/Icon/Icon.doc.mjs: clear; matches the code.
  • File docs/specs/components/Icon/Icon.spec.md: awaits the owner decision; the edited row's basis and verification cells need updating if accepted.
  • File .changeset/icon-name-alias.md: clear; matches the code.

Automated review (maintainer link)

Comment thread packages/core/src/Icon/Icon.test.tsx Resolved
Comment thread packages/core/src/Icon/Icon.tsx Resolved
Comment thread docs/specs/components/Icon/Icon.spec.md Resolved
@josephfarina
josephfarina marked this pull request as ready for review November 17, 2026 19:26
@josephfarina

Copy link
Copy Markdown
Contributor Author

Owner decision (engineering owner, covering this pull request): an Icon given name instead of icon renders that glyph instead of crashing the page, and in development warns once per mounted Icon, naming the prop to use. name is read only when it is an icon key string or an icon component, and the types are unchanged, so typed code still reports the mistake. The Icon record states this, and tests cover it.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 1d78d3e

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: an engineering owner has approved the new component:Icon FR1 sentence for this head, and two fixes remain.

  • isGlyphSource (packages/core/src/Icon/Icon.tsx, lines 403-409) does not accept React.memo icon components, so <Icon name={memo(MyIcon)} /> still throws "Element type is invalid" with no warning, although icon accepts the same component and the new FR1 sentence, the changeset and the docs say any icon component given as name renders; please also accept memo and lazy component types and add a test for that case.
  • The description says TypeScript does not flag <Icon name="check" />, but tsc reports TS2741 ("Property 'icon' is missing") because icon is required, so please say instead that the crash reaches code that is not type-checked.

The new test for name beside icon closes the earlier test gap. The earlier comment suggestion on the readGlyph JSDoc still applies, and the FR1 row's Basis cell could name the owner decision.

Claims and files checked

Review mode: full; reason: spec-record

  • Claim (title): a glyph given as name renders and warns instead of crashing: verified for keys and for plain and forwardRef components; false for memo-wrapped components.
  • Claim (changeset): Icon renders a glyph given as name, warns in development to use icon, and keeps name off the DOM: verified by the new tests, except for memo-wrapped components.
  • Claim (description): without icon, Icon renders undefined as the element type and the whole render fails: verified on the base.
  • Claim (description): TypeScript does not flag the call: false; TS2741.
  • Claim (description): a call without icon reads name when it is a key or an icon component, and a call with icon is unchanged: verified, except memo-wrapped components; name beside icon still reaches the element.
  • Claim (description): the Icon record's FR1 states the fallback and types are unchanged: verified; the public API surface shows no change.
  • Claim (description): one helper and one development-warning call, with no type, default or styling change: verified; the helper uses one private predicate.
  • Claim (description): four new test cases with the listed names: verified.
  • Claim (description): 16 of 19 crashing generated pages now render: not verifiable from the repository.
  • Claim (description): the Icon test suites pass with 169 tests: verified.
  • File packages/core/src/Icon/Icon.tsx: blocking memo gap; one comment suggestion.
  • File packages/core/src/Icon/Icon.test.tsx: clear; no memo case yet.
  • File packages/core/src/Icon/Icon.doc.mjs: matches the code except the memo gap.
  • File docs/specs/components/Icon/Icon.spec.md: owner-approved for this head; Basis cell note.
  • File .changeset/icon-name-alias.md: matches the code except the memo gap.

Automated review (maintainer link)

Comment thread packages/core/src/Icon/Icon.tsx Resolved
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 4d20d64

@github-actions github-actions Bot added needs:spec-owner-review Current knowledge records await owner approval and removed needs:spec-owner-review Current knowledge records await owner approval labels Nov 17, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the name fallback now renders every React component type, and the earlier memo and TypeScript findings are fixed, but CI's Lint check fails on the new test and two description lines are stale.

  • packages/core/src/Icon/Icon.test.tsx line 1156 calls forwardRef, which the repository's strict lint (run by CI's pnpm lint) rejects with @eslint-react/no-forward-ref, so the Lint check fails; testing name={CheckCircleIcon} and name={memo(CheckCircleIcon)} instead (Heroicons icons are already forwardRef components, and the file imports one) fixes it and also covers a bare forwardRef component, which today's case reaches only inside memo.
  • The description's Testing line (169 tests, eslint clean) and its Writing rubric R3 line ("no basis cell changed") no longer match the pull request, which runs 170 tests and changes FR1's Basis cell and Verification map, so please update both after the lint fix.

The engineering owner's /approve-spec for this head covers the new FR1 sentence. Non-blocking: the isGlyphSource JSDoc restates its name, and no case covers a lazy component given as name.

Claims and files checked

Review mode: full; reason: spec-record

  • Claim (title): a glyph given as name renders and warns instead of crashing: verified; the new cases fail on the base with "Element type is invalid" and pass on the head.
  • Claim (changeset): Icon renders a glyph given as name, warns in development to use icon, and keeps name off the DOM: verified by the new tests, a probe and a browser fixture; a patch bump fits.
  • Claim (description): without icon, Icon renders undefined as the element type and the whole render fails: verified on the base.
  • Claim (description): TypeScript reports the missing icon, and the crash reaches code that is not type-checked: verified; icon stays required.
  • Claim (description): without icon, name is read when it is a key or an icon component, including memo, forwardRef and lazy, stays off the DOM, and warns; a call with icon is unchanged: verified.
  • Claim (description): the Icon record's FR1 states the fallback, and types are unchanged: verified; the public API surface shows no change.
  • Claim (description): one helper and one development-warning call, with no type, default or styling change: verified.
  • Claim (description): five new test cases with the listed names: verified.
  • Claim (description): 16 of 19 crashing generated pages now render: not verifiable from the repository.
  • Claim (description): 169 tests pass, and eslint, prettier and tsc --noEmit are clean: false; 170 pass and strict eslint fails at Icon.test.tsx:1156; prettier and tsc are clean.
  • Claim (description): writing rubric R1, R2 and R4 to R7: verified; R3 "no basis cell changed": false, since the FR1 Basis cell and Verification map changed (neither cites a pull request).
  • Claim (description): one defect restored, with no public API hidden under the fix: verified.
  • File packages/core/src/Icon/Icon.tsx: clear, with one comment suggestion.
  • File packages/core/src/Icon/Icon.test.tsx: blocking lint error at line 1156; no lazy case.
  • File packages/core/src/Icon/Icon.doc.mjs: clear; matches the code.
  • File docs/specs/components/Icon/Icon.spec.md: owner-approved for this head; its FR1 Verification row lists a bare forwardRef case the suite does not exercise yet.
  • File .changeset/icon-name-alias.md: clear; matches the code.

Automated review (maintainer link)

Comment thread packages/core/src/Icon/Icon.test.tsx Resolved
Comment thread packages/core/src/Icon/Icon.tsx Resolved
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 2d27454

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: the name fallback matches the Icon record's FR1 sentence, which an engineering owner approved for this head, the new tests fail on the base and pass on the head, and the earlier lint and description findings are fixed. CI's main workflow has not run on this head yet (it was refused because CI was full), so re-run it before merging.

  • Non-blocking: a lazy component given as name renders, but no test case covers it.
Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Claim: Changeset: a glyph given as name renders and warns in development to use icon, instead of failing with "Element type is invalid", and name does not reach the DOM: verified (Icon.tsx:385-395; Icon.test.tsx:1120-1164, which fail on the base).
  • Claim: On the base, a name-only Icon fails the whole render with "Element type is invalid … got: undefined": verified (the three new name cases fail on the base with that error).
  • Claim: Several popular icon libraries call the glyph prop name: verified (for example react-native-vector-icons and Ionicons).
  • Claim: TypeScript reports the missing icon: verified (icon is required, Icon.tsx:194; IconProps unchanged).
  • Claim: Generated-page corpus figures (second most common crash; 16 of 19 pages now render, 3 stop at another component, none regress): not checkable from the repository; no code claim depends on them.
  • Claim: Cause: without icon, Icon takes component mode and renders undefined: verified (component branch, Icon.tsx:354-356).
  • Claim: After the change, a key, namespaced key or icon component (memo, forwardRef and lazy included) given as name is read, kept off the DOM, and warns; a call with icon is unchanged: verified (Icon.test.tsx:1120-1187; lazy and namespaced keys by probe).
  • Claim: The record's FR1 states the fallback and types are unchanged: verified (Icon.spec.md:94; public API delta none).
  • Claim: One helper and one useDevWarning call, no type, default or styling change: verified (readGlyph with its predicate, Icon.tsx:323-328, :385-414).
  • Claim: Result: name="check" renders the glyph without a name attribute and warns once: verified (Icon.test.tsx:1120-1136).
  • Claim: icon="check" renders and does not warn: verified (Icon.test.tsx:1181-1187).
  • Claim: Five new test cases as listed: verified (Icon.test.tsx:1119-1187).
  • Claim: Scope and checklist (Icon only, one defect, no hidden API, default or interaction change, no internal context): verified (only Icon changes; no API row; no private residue found).
  • Claim: Testing: 170 passed; strict eslint, prettier and tsc clean: verified (170 passed in 6 files; strict eslint has no error in Icon; prettier and the Core typecheck pass).
  • Claim: Writing rubric R1 to R7: verified (FR1 is present tense; its Basis names the owner decision; the changed lines hold no research, alternatives, change references, open questions or status).
  • File: .changeset/icon-name-alias.md: clear
  • File: docs/specs/components/Icon/Icon.spec.md: clear
  • File: packages/core/src/Icon/Icon.doc.mjs: clear
  • File: packages/core/src/Icon/Icon.test.tsx: non-blocking note (no lazy case)
  • File: packages/core/src/Icon/Icon.tsx: clear

Automated review (maintainer link)

warn.mockRestore();
});

it('renders forwardRef and memo icon components given as name', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: the description says a lazy component given as name renders, and it does, but no case covers isGlyphSource's react.lazy branch. A case like this would keep it covered:

const LazyCheck = lazy(async () => ({default: TestIcon}));
render(
  <Suspense fallback={null}>
    <Icon {...({name: LazyCheck, 'data-testid': 'lazy'} as unknown as Parameters<typeof Icon>[0])} />
  </Suspense>,
);
expect((await screen.findByTestId('lazy')).tagName.toLowerCase()).toBe('svg');

josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12680 perf(cli): a template's component line resolves its names in one pass, not one full lookup per name
  Author: Joey <[email protected]>
- #12180 fix(core): Calendar weekday names widen their column instead of overlapping
  Author: Joey <[email protected]>
- #12159 feat(cli): make an icon set inside your own app
  Author: Joey Farina <[email protected]>
- #12383 fix(Grid): a responsive column shrinks to a container narrower than minWidth
  Author: Joey Farina <[email protected]>
- #12374 [fix] Icon: a glyph given as name renders and warns, instead of crashing
  Author: Joey Farina <[email protected]>
- #12453 fix(charts): line, area and band default to straight segments
  Author: josephfarina <[email protected]>
- #12296 fix(core): a neutral Badge in a primary or destructive Button meets 4.5:1 on its fill
  Author: Joey Farina <[email protected]>
- #12395 fix(CodeBlock): without a code string, CodeBlock names the prop and the fix in development
  Author: Joey Farina <[email protected]>
- #12260 fix(cli): `astryx component Flex` names Stack first
  Author: Joey Farina <[email protected]>
- #12391 fix(core): a two-lane Toolbar wraps instead of squeezing its start lane
  Author: Joey Farina <[email protected]>
- #12427 fix(core): checkbox and radio marks keep their share of the box a theme sizes
  Author: josephfarina <[email protected]>
- #12725 [experimental] cli: with no icon set, experimental icon names the discover search where it lists packs
  Author: Joey Farina <[email protected]>
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12738.

@github-actions
github-actions Bot deleted the josephfarina/rl-icon-name-alias branch November 19, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — 2d27454b Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant