Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Summary

Fixed object forms in Storybook that were stuck displaying "Loading form..." by correcting the property name from fields to customFields when passing field objects.

Changes Made

  • Fix ContactForm story to use customFields instead of fields
  • Fix OpportunityForm story to use customFields instead of fields
  • Fix BasicSchema story to use customFields instead of fields
  • Fix ComplexFields story to use customFields instead of fields
  • Verify the fix works - both Contact and Opportunity forms load correctly
  • Run code review - no issues found
  • Run security checks - no vulnerabilities found

Root Cause

According to the ObjectFormSchema type definition:

  • fields should be an array of field names (strings)
  • customFields should be an array of field objects (FormField[])

The stories were incorrectly passing field objects to fields instead of customFields, causing the ObjectForm component to attempt fetching the schema from the dataSource, resulting in an infinite loading state.

Screenshot

Contact Form Fixed

The forms now display all fields correctly:

  • Contact Form: Name*, Email*, Phone, Title, Company, Status
  • Opportunity Form: Opportunity Name*, Amount*, Stage, Close Date, Description
Original prompt

拉取请求: #264

object form一直显示Loading form...


💡 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.

@vercel
Copy link

vercel bot commented Jan 29, 2026

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

Project Deployment Review Updated (UTC)
objectui Ready Ready Preview, Comment Jan 29, 2026 4:00pm
objectui-components Ready Ready Preview, Comment Jan 29, 2026 4:00pm
objectui-crm-app Error Error Jan 29, 2026 4:00pm

Request Review

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong hotlong merged commit 984541a into copilot/integrate-msw-into-storybook Jan 29, 2026
7 of 8 checks passed
Copilot AI requested a review from hotlong January 29, 2026 16:04
Copilot stopped work on behalf of hotlong due to an error January 29, 2026 16:04
Copy link
Contributor

Copilot AI left a 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 customFields instead of fields for 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 mode property is required according to the ObjectFormSchema type definition but is missing from this story configuration. This will cause TypeScript type errors and potential runtime issues. Add the mode property 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 mode property is required according to the ObjectFormSchema type definition but is missing from this story configuration. This will cause TypeScript type errors and potential runtime issues. Add the mode property 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 mode property is required according to the ObjectFormSchema type definition but is missing from this story configuration. This will cause TypeScript type errors and potential runtime issues. Add the mode property 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 mode property is required according to the ObjectFormSchema type definition but is missing from this story configuration. This will cause TypeScript type errors and potential runtime issues. Add the mode property 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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants