Repository navigation
[fix] Icon: a glyph given as name renders and warns, instead of crashing - #12374
josephfarina wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
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" />, buttscreports TS2741 ("Property 'icon' is missing") becauseiconis 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
namerenders and warns instead of crashing: verified; both newnametests fail on the base with "Element type is invalid" and pass on the head. - Claim (changeset): Icon renders a
nameglyph, warns in development to useicon, and keepsnameoff the DOM: verified by the new tests and a rendered check. - Claim (description): without
icon, Icon rendersundefinedas 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
iconis unchanged and types are unchanged: verified;namebesideiconstill 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.
|
Owner decision (engineering owner, covering this pull request): an |
|
/approve-spec 1d78d3e |
There was a problem hiding this comment.
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 acceptReact.memoicon components, so<Icon name={memo(MyIcon)} />still throws "Element type is invalid" with no warning, althoughiconaccepts the same component and the new FR1 sentence, the changeset and the docs say any icon component given asnamerenders; 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" />, buttscreports TS2741 ("Property 'icon' is missing") becauseiconis 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
namerenders 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 useicon, and keepsnameoff the DOM: verified by the new tests, except for memo-wrapped components. - Claim (description): without
icon, Icon rendersundefinedas 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
iconreadsnamewhen it is a key or an icon component, and a call withiconis unchanged: verified, except memo-wrapped components;namebesideiconstill 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.
|
/approve-spec 4d20d64 |
There was a problem hiding this comment.
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.tsxline 1156 callsforwardRef, which the repository's strict lint (run by CI'spnpm lint) rejects with@eslint-react/no-forward-ref, so the Lint check fails; testingname={CheckCircleIcon}andname={memo(CheckCircleIcon)}instead (Heroicons icons are alreadyforwardRefcomponents, and the file imports one) fixes it and also covers a bareforwardRefcomponent, which today's case reaches only insidememo.- 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
namerenders 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 useicon, and keepsnameoff the DOM: verified by the new tests, a probe and a browser fixture; a patch bump fits. - Claim (description): without
icon, Icon rendersundefinedas 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;iconstays required. - Claim (description): without
icon,nameis read when it is a key or an icon component, including memo, forwardRef and lazy, stays off the DOM, and warns; a call withiconis 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 --noEmitare clean: false; 170 pass and strict eslint fails atIcon.test.tsx:1156; prettier andtscare 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.
|
/approve-spec 2d27454 |
There was a problem hiding this comment.
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
lazycomponent given asnamerenders, 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
namerenders and warns in development to useicon, instead of failing with "Element type is invalid", andnamedoes 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
namecases 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 (iconis required,Icon.tsx:194;IconPropsunchanged). - 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 rendersundefined: 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
nameis read, kept off the DOM, and warns; a call withiconis 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
useDevWarningcall, no type, default or styling change: verified (readGlyphwith its predicate,Icon.tsx:323-328,:385-414). - Claim: Result:
name="check"renders the glyph without anameattribute 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
tscclean: 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
| warn.mockRestore(); | ||
| }); | ||
|
|
||
| it('renders forwardRef and memo icon components given as name', () => { |
There was a problem hiding this comment.
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');- #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]>
|
Landed in #12738. |
Record change (component:Icon): FR1 now says that without
icon, anamethat is a key string or an icon component is the glyph source; it does not reach the DOM, and a development warning namesicon. Its Basis names the owner decision, and the verification map lists the test suite. Types are unchanged.Proof:
Icon.test.tsxcovers a key, a plain component, forwardRef and memo components given asname,namebesideicon, andiconwithout a warning. Icon + IconButton: 170/170 pass withCI=1. Strict eslint, prettier andtsc --noEmitare 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 withicon, 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 propname. TypeScript reports the missingicon, 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
icon, Icon takes the component-mode branch and rendersundefinedas the element type.iconreadsnameas the glyph when it is one (a semantic key, namespaced key or icon component, including memo, forwardRef and lazy components), keeps thatnameoff the DOM, and a development warning says to passicon. A call withiconis unchanged.Expected behavior and authority
component:IconFR1 (Icon presents one glyph from the supplied source); the record's FR1 now states thenamefallback. Types are unchanged:iconstays the documented, required prop.Smallest restoration
One helper (
readGlyph) and oneuseDevWarningcall inIcon.tsx. No type, default or styling change.Evidence
<Icon name="check" />throws "Element type is invalid".checkglyph without anameattribute, and warns once in development.<Icon icon="check" />renders and does not warn.Icon.test.tsx(registry key as name, component as name, forwardRef and memo components as name,namepassed through untouched wheniconis given, icon given without a warning).<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
Testing
CI=1 vitest run packages/core/src/Icon packages/core/src/IconButton(170 passed); strict eslint (ASTRYX_STRICT_LINT=1), prettier andtsc --noEmiton 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.