-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP] Fix object form loading display issue #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Fix object form loading display issue #266
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
984541a
into
copilot/integrate-msw-into-storybook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes object forms in Storybook that were stuck displaying "Loading form..." by correcting the property name from fields to customFields when passing field objects. The root cause was correctly identified: according to the ObjectFormSchema type definition, fields expects an array of field names (strings), while customFields expects an array of field objects (FormField[]).
Changes:
- Updated 4 story configurations to use
customFieldsinstead offieldsfor passing field object arrays - Stories affected: BasicSchema, ComplexFields, ContactForm, and OpportunityForm
Comments suppressed due to low confidence (4)
packages/components/src/stories-json/object-form.stories.tsx:85
- The
modeproperty is required according to theObjectFormSchematype definition but is missing from this story configuration. This will cause TypeScript type errors and potential runtime issues. Add themodeproperty with a value of 'create', 'edit', or 'view'.
args: {
type: 'object-form',
objectName: 'Product',
customFields: [
{ name: 'name', label: 'Product Name', type: 'text', required: true },
{ name: 'category', label: 'Category', type: 'select', options: ['Electronics', 'Clothing', 'Food'], required: true },
{ name: 'price', label: 'Price', type: 'number', required: true },
{ name: 'inStock', label: 'In Stock', type: 'checkbox' },
{ name: 'description', label: 'Description', type: 'textarea', rows: 4 }
],
className: 'w-full max-w-2xl'
} as any,
packages/components/src/stories-json/object-form.stories.tsx:108
- The
modeproperty is required according to theObjectFormSchematype definition but is missing from this story configuration. This will cause TypeScript type errors and potential runtime issues. Add themodeproperty with a value of 'create', 'edit', or 'view'.
args: {
type: 'object-form',
objectName: 'contact',
customFields: [
{ name: 'name', label: 'Name', type: 'text', required: true },
{ name: 'email', label: 'Email', type: 'email', required: true },
{ name: 'phone', label: 'Phone', type: 'tel' },
{ name: 'title', label: 'Title', type: 'text' },
{ name: 'company', label: 'Company', type: 'text' },
{ name: 'status', label: 'Status', type: 'select', options: ['Active', 'Lead', 'Customer'] }
],
className: 'w-full max-w-2xl'
} as any,
packages/components/src/stories-json/object-form.stories.tsx:129
- The
modeproperty is required according to theObjectFormSchematype definition but is missing from this story configuration. This will cause TypeScript type errors and potential runtime issues. Add themodeproperty with a value of 'create', 'edit', or 'view'.
args: {
type: 'object-form',
objectName: 'opportunity',
customFields: [
{ name: 'name', label: 'Opportunity Name', type: 'text', required: true },
{ name: 'amount', label: 'Amount', type: 'number', required: true },
{ name: 'stage', label: 'Stage', type: 'select', options: ['Prospecting', 'Qualification', 'Proposal', 'Negotiation', 'Closed Won', 'Closed Lost'] },
{ name: 'closeDate', label: 'Close Date', type: 'date' },
{ name: 'description', label: 'Description', type: 'textarea', rows: 4 }
],
className: 'w-full max-w-2xl'
} as any,
packages/components/src/stories-json/object-form.stories.tsx:42
- The
modeproperty is required according to theObjectFormSchematype definition but is missing from this story configuration. This will cause TypeScript type errors and potential runtime issues. Add themodeproperty with a value of 'create', 'edit', or 'view'.
args: {
type: 'object-form',
objectName: 'User',
customFields: [
{ name: 'firstName', label: 'First Name', type: 'text', required: true },
{ name: 'lastName', label: 'Last Name', type: 'text', required: true },
{ name: 'email', label: 'Email', type: 'email', required: true },
{ name: 'age', label: 'Age', type: 'number' }
],
className: 'w-full max-w-2xl'
} as any,
Summary
Fixed object forms in Storybook that were stuck displaying "Loading form..." by correcting the property name from
fieldstocustomFieldswhen passing field objects.Changes Made
customFieldsinstead offieldscustomFieldsinstead offieldscustomFieldsinstead offieldscustomFieldsinstead offieldsRoot Cause
According to the
ObjectFormSchematype definition:fieldsshould be an array of field names (strings)customFieldsshould be an array of field objects (FormField[])The stories were incorrectly passing field objects to
fieldsinstead ofcustomFields, causing the ObjectForm component to attempt fetching the schema from the dataSource, resulting in an infinite loading state.Screenshot
The forms now display all fields correctly:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.