Repository navigation
[fix] Heading: a missing level renders an h2 and warns, instead of crashing - #12372
josephfarina wants to merge 2 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 ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| TopNav | 79.6 kB (+335 B) · 11.8 kB CSS (0) | — | — · — · — |
| MobileNav | 77.8 kB (+320 B) · 11.4 kB CSS (0) | — | — · — · — |
| AppShell | 99.0 kB (+281 B) · 14.4 kB CSS (0) | — | — · — · — |
23 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/DialogHeroHeader | 90.6 kB (+281 B) · 372 B CSS (0) | — | — · — · — |
| DrawerHeader | 69.5 kB (+271 B) · 13.8 kB CSS (0) | — | — · — · — |
| DialogHeader | 69.4 kB (+247 B) · 12.4 kB CSS (0) | — | — · — · — |
| Heading | 13.9 kB (+225 B) · 5.5 kB CSS (0) | — | — · — · — |
| lab/TourStep | 95.1 kB (+223 B) · 691 B CSS (0) | — | — · — · — |
| MultiSelector | 103.4 kB (+218 B) · 17.8 kB CSS (0) | — | — · — · — |
| PowerSearch | 310.4 kB (+201 B) · 25.6 kB CSS (0) | — | — · — · — |
| lab/Comments | 377.1 kB (+191 B) · 2.5 kB CSS (0) | — | — · — · — |
| Markdown | 205.5 kB (+189 B) · 22.1 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 309.3 kB (+186 B) · 454 B CSS (0) | — | — · — · — |
| lab/CommentThread | 370.3 kB (+185 B) · 2.4 kB CSS (0) | — | — · — · — |
| Selector | 114.9 kB (+184 B) · 18.7 kB CSS (0) | — | — · — · — |
| SideNav | 122.6 kB (+175 B) · 12.2 kB CSS (0) | — | — · — · — |
| Pagination | 147.8 kB (+174 B) · 19.1 kB CSS (0) | — | — · — · — |
| AlertDialog | 130.1 kB (+165 B) · 15.5 kB CSS (0) | — | — · — · — |
| DropdownMenu | 108.9 kB (+141 B) · 18.9 kB CSS (0) | — | — · — · — |
| MoreMenu | 109.2 kB (+137 B) · 18.9 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 104.5 kB (+128 B) · 19.1 kB CSS (0) | — | — · — · — |
| TableCell | 104.7 kB (+127 B) · 19.3 kB CSS (0) | — | — · — · — |
| ContextMenu | 103.4 kB (+119 B) · 18.8 kB CSS (0) | — | — · — · — |
| Table | 121.9 kB (+116 B) · 19.8 kB CSS (0) | — | — · — · — |
| Text · Storybook | 13.1 kB (0) · 5.5 kB CSS (0) | 859 (0) | ✓ · ✓ · — |
| Tokenizer | 105.8 kB (0) · 20.4 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.65 MB packed (+861 B); no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
|
Owner decision (engineering owner, covering this pull request): a |
|
/approve-spec 0a7c720 |
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about the new Heading fallback, and two fixes are needed.
The current component:Heading record does not state the fallback that this pull request writes into FR1 and the Level row: the h2 level, the development warning, and which inputs count as a level. An engineering owner must approve or amend it by commenting /approve-spec with the full head commit SHA, and the author can do this as an engineering owner.
- A bare
level(level={true}) renders anh1, becauseresolveLevelconverts any value withNumber(), while the changeset, the doc and the proposed FR1 say that a level that is not 1–6 rendersh2; convert only numbers and strings, and add a boolean test case. - The changeset lists "A numeric string such as
level=\"3\"reads as its number" as part of the fix, butlevel="3"already renderedh3before this change, so say instead that it keeps rendering its level and now warns in development.
The new tests fail on the base and pass on the head, and every valid level renders exactly as before.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim (changeset): a heading without a level from 1 to 6 renders
h2and warns. False for a barelevel, which rendersh1. - Claim (changeset): it no longer fails with "Element type is invalid". Verified: the new tests fail with that error on the base.
- Claim (changeset): a numeric string reads as its number. True, but
level="3"already did before this change. - Claim (description): a missing level crashed the render. Verified.
- Claim (description): TypeScript already flags a missing level. Verified:
levelis required. - Claim (description): the fallback is
h2at the level 2 scale with a warning that names the prop and the fix. Verified. - Claim (description): it warns once, in development only. Verified.
- Claim (description): typed callers and valid levels see no change. Verified.
- Claim (description): one resolver and one warning call, with no type, default or styling change for a valid level. Verified.
- Claim (description): three new test cases, 39 tests passing, lint and formatting clean. Verified.
- Claim (description): the record's review check calls for a level baseline. The quote exists, but it is about theme-added types and does not decide this fallback.
- Claim (description): the share of agent-written pages that now render. Not checkable from the repository.
- Claim (description): no internal context in public text. Verified.
- File
packages/core/src/Heading/Heading.tsx: finding (a barelevelrendersh1; the warning drops the quotes from string values). - File
packages/core/src/Heading/Heading.test.tsx: clear. - File
packages/core/src/Text/Heading.doc.mjs: finding (theh2statement is false for a barelevel). - File
docs/specs/components/Heading/Heading.spec.md: needs an engineering owner's decision; the Level row's "other value renders level 2" disagrees with FR1 on numeric strings. - File
.changeset/heading-missing-level.md: finding (numeric strings presented as fixed; theh2statement).
|
I'll run a full review to re-check this with your note. |
There was a problem hiding this comment.
Changes requested: an engineering owner's approval settles the new Heading fallback, and two fixes remain.
- A bare
level(<Heading level>, which passestrue) renders anh1, becauseresolveLevelconverts any value withNumber(), while the approved FR1, the changeset and the doc say that a level that is not 1–6 rendersh2; convert only numbers and strings, and add a boolean test case. - The changeset lists "A numeric string such as
level="3"reads as its number" as part of the fix, butlevel="3"already renderedh3before this change, so say instead that it keeps rendering its level and now warns in development.
The new tests fail on the base and pass on the head, and every valid level renders exactly as before. Two smaller points: quote string values in the warning message, and make the record's Level row agree with FR1 about numeric strings.
Claims and files checked
Review mode: same-head; reason: none
- Claim (changeset): a heading without a level from 1 to 6 renders
h2and warns. False for a barelevel, which rendersh1. - Claim (changeset): it no longer fails with "Element type is invalid". Verified: the missing-level test fails with that error on the base and passes on the head.
- Claim (changeset): a numeric string reads as its number. True, but
level="3"already renderedh3before this change, and the new warning is not mentioned. - Claim (description): a missing or out-of-range level crashed the whole render because the tag lookup returned nothing. Verified on the base.
- Claim (description): TypeScript already flags a missing level. Verified:
levelis required. - Claim (description): the fallback is
h2at the level 2 scale, with a development warning that names the prop and the fix. Verified. - Claim (description): a numeric string reads as its number and also warns. Verified.
- Claim (description): the record's FR1 and Level row state the runtime fallback. Verified, and an engineering owner approved them at this head.
- Claim (description): the record's review check calls for a level baseline. The quoted check exists, but it is about the scale a theme-added type keeps, not this fallback.
- Claim (description): typed callers and valid levels see no change, with no type, default or styling change for a valid level. Verified.
- Claim (description): one resolver and one warning call. Verified.
- Claim (description): a level-less heading threw before and now renders an
h2withdata-level="2"and warns once;level={4}rendersh4without a warning. Verified. - Claim (description): three new test cases, 39 tests passing, lint and formatting clean. Verified: 39 pass at the head, and the Lint workflow passed.
- Claim (description): the share of generated pages that now render. Not checkable from the repository.
- Claim (description): the record changes use the present tense and add no open questions or project status. Verified.
- Claim (description): no internal context in public text. Verified.
- File
packages/core/src/Heading/Heading.tsx: finding (a barelevelrendersh1; the warning drops the quotes from string values). - File
packages/core/src/Heading/Heading.test.tsx: clear. - File
packages/core/src/Text/Heading.doc.mjs: itsh2statement is false for a bareleveluntil the resolver is fixed. - File
docs/specs/components/Heading/Heading.spec.md: approved by an engineering owner at this head; non-blocking (the Level row and FR1 disagree about numeric strings, and the verification map does not name the new tests). - File
.changeset/heading-missing-level.md: finding (numeric strings presented as fixed; theh2statement is false for a barelevel).
…lues in the warning
|
/approve-spec 9b67f41 |
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet.
The Heading fallback matches the record change an engineering owner approved for this head, and both earlier fixes are in: a bare level now renders an h2, and the changeset describes level="3" accurately. The new tests fail on the base and pass on the head, and every valid level renders as before. One optional follow-up: name the new fallback cases in the record's verification map row for FR1.
Claims and files checked
Review mode: full; reason: spec-record
- Claim (changeset): a heading without a level from 1 to 6 renders
h2and warns in development, instead of failing with "Element type is invalid". Verified: the missing-level and bare-level tests fail with that error on the base and pass on the head. - Claim (changeset):
level="3"keeps rendering its level and now warns. Verified:h3with no warning on the base,h3with one warning on the head. - Claim (description): a missing or out-of-range level failed the whole render because the tag lookup returned nothing. Verified on the base.
- Claim (description): TypeScript already flags a missing level, and the type stays required. Verified.
- Claim (description): the fallback is
h2at the level 2 scale, with a development warning that names the prop and the fix. Verified. - Claim (description): a numeric string keeps its level and now warns, and a bare
levelrenders level 2. Verified. - Claim (description): the record's FR1 and Level row state the fallback. Verified, and an engineering owner approved them at this head.
- Claim (description): the record's review check calls for a level baseline. The quoted check exists; it concerns the scale a theme-added type keeps, and the fallback rests on the approved FR1.
- Claim (description): one resolver plus one warning call, with no type, default or styling change for a valid level. Verified.
- Claim (description): a level-less heading threw before and now renders an
h2withdata-level="2"and warns once;level={4}rendersh4without a warning. Verified. - Claim (description): four new test cases, 40 tests passing, lint and formatting clean. Verified.
- Claim (description): the share of generated pages that now render. Not checkable from the repository.
- Claim (description): the record text uses the present tense and adds no research, open questions or project status. Verified.
- Claim (description): no internal context in public text. Verified.
- File
packages/core/src/Heading/Heading.tsx: clear. - File
packages/core/src/Heading/Heading.test.tsx: clear. - File
packages/core/src/Text/Heading.doc.mjs: clear. - File
docs/specs/components/Heading/Heading.spec.md: approved at this head; non-blocking note on the verification map. - File
.changeset/heading-missing-level.md: clear.
- #12694 fix(cli): the Order Detail template's discount uses a minus sign held to its amount Author: @josephfarina - #12114 fix(templates): reset, reply, send and go-into icons mirror in right-to-left pages Author: @josephfarina - #12143 refactor(templates): example blocks lay out with HStack and VStack instead of flex wrappers Author: @josephfarina - #12158 fix(core): ChatComposer keeps its send action inside the composer on a narrow screen Author: @josephfarina - #12242 fix(cli): the npm commands the CLI runs for itself use npm's own noproxy setting Author: @josephfarina - #12283 fix(core): dark secondary text meets 4.5:1 on the neutral fill over the page and cards Author: @josephfarina - #12290 fix(Markdown): keep bulleted and numbered lists inside their column Author: @josephfarina - #12372 [fix] Heading: a missing level renders an h2 and warns, instead of crashing Author: @josephfarina - #12447 spec(AST-057): the swipe codemod's paths match it in any lifecycle folder Author: @josephfarina - #12475 fix(templates): on a phone the settings search moves under the title Author: @josephfarina - #12530 fix(cli): the contact-form template fits a phone; its section fills the width up to 800px Author: @josephfarina
|
Landed in #12812. |
Record change (component:Heading): FR1 and the Level row now say that a missing
level, or one that is not 1–6, rendersh2at the level 2 scale and warns in development, and that a numeric string reads as its number. Types are unchanged.Proof:
Heading.test.tsxcovers a missing level, a numeric string, a barelevel(true) and a valid level without a warning: 40/40 pass withCI=1. Prettier, eslint andtsc --noEmitare clean. Gate result: on a frozen set of agent-written pages, 32 of 35 that crashed on a level-less Heading now render (16 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 valid level, so there are no before/after pictures.User impact
A page that renders
<Heading>withoutlevel(or with a value outside 1–6) fails the whole render with React's "Element type is invalid … got: undefined", becauselevelToTag[undefined]isundefined. TypeScript flags the missing prop, but JavaScript callers, untyped generated pages and pages rendered without a type check reach runtime. Generated pages hit this often: agents carry over<Heading>and<Heading size="lg">from other libraries. In a corpus of agent-written pages, it was the most common render crash.Problem and solution fit
h2at the level 2 scale, the common section heading, and a development warning names the prop and the fix (Heading: level must be 1, 2, 3, 4, 5 or 6, but it is undefined. … <Heading level={2}>). A numeric string such aslevel="3"keeps rendering its level and now warns; other values (a barelevel, which passestrue) render as level 2.Expected behavior and authority
component:Headingreview check: "Reject … a heading that renders without a level baseline". The record's FR1 and Level row now state the runtime fallback. The type stayslevel: HeadingLevel(required), so typed callers see no change.Smallest restoration
One resolver (
resolveLevel) plus oneuseDevWarningcall inHeading.tsx. No type, default or styling change for a valid level.Evidence
<Heading>Overview</Heading>throws "Element type is invalid".<h2 data-level="2">and warns once in development.<Heading level={4}>rendersh4and does not warn.Heading.test.tsx(missing level, numeric string, barelevelthat passestrue, valid level without a warning).Scope
Components: Heading
Testing
CI=1 vitest run packages/core/src/Heading/Heading.test.tsx(40 passed); eslint and prettier on the changed files.Writing rubric results
R1 narration: none; FR1 and the Level row describe current behavior in the present tense.
R2 research: none in the record; the corpus numbers are only in this description.
R3 evidence: FR1 basis stays "Current source and tests".
R4 rejected alternatives: none recorded.
R5 change references: none.
R6 open questions: none.
R7 project status: none.