Skip to content

fix(docsite): give Timestamp playground a valid default value#3224

Open
cixzhang wants to merge 1 commit into
mainfrom
navi/fix/issue-2877-bb002-timestamp-playground-default
Open

fix(docsite): give Timestamp playground a valid default value#3224
cixzhang wants to merge 1 commit into
mainfrom
navi/fix/issue-2877-bb002-timestamp-playground-default

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Problem

Opening the Timestamp component page on the docsite renders Render error: Invalid time value in the interactive properties-tab preview on load.

Timestamp's required prop value: string | number has no semantic default. The docsite's preview state builder (getRequiredFallbackValue in apps/docsite/src/components/component-detail/interactiveState.ts) falls back to the prop's own name for required string props — so value becomes the literal string "value". Timestamp then calls new Date("value").toISOString(), which throws Invalid time value, surfaced by the preview error boundary.

Root cause

Timestamp.doc.mjs had no playground.defaults block, so the preview used the generic required-string fallback ("value") — not a real date.

Fix

Add a playground.defaults.value to Timestamp.doc.mjs with a valid ISO 8601 date (2026-02-19T17:00:00Z), matching the existing pattern used by Icon and Skeleton docs to seed required, non-generatable props. This flows through the generated component registry into buildInitialState, so the preview now renders a real formatted timestamp instead of crashing.

Reproduction (red → green)

Added a unit test in apps/docsite/src/__tests__/component-preview-state.test.ts (alongside the existing Icon/Skeleton cases):

  • Asserts the un-defaulted required value falls back to the string "value", and that new Date("value").toISOString() throws Invalid time value — demonstrating the crash.
  • Asserts the playground default seeds a valid date the component can render, with no missing required props.

Verified the test fails when the default is the buggy "value" and passes with the valid ISO date:

× gives Timestamp a valid date value via playground defaults
  → expected 'value' to be '2026-02-19T17:00:00Z'   (before fix)
✓ gives Timestamp a valid date value via playground defaults   (after fix)

Confirmed the generated componentRegistry now carries Timestamp.playground.defaults.value = "2026-02-19T17:00:00Z".

Refs #2877 (BB-002)

Timestamp's required `value` prop had no semantic default, so the
interactive preview fell back to the literal string "value" and crashed
with "Invalid time value". Seed a valid ISO 8601 date via
playground.defaults so the preview renders.
@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jun 28, 2026 3:21pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Jun 28, 2026
@cixzhang cixzhang marked this pull request as ready for review June 28, 2026 15:36
@cixzhang cixzhang enabled auto-merge (squash) June 28, 2026 15:36
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