Skip to content

Fix component registration conflicts in test environment#316

Merged
hotlong merged 5 commits intocopilot/fix-step-8-errorfrom
copilot/add-custom-action-step
Feb 1, 2026
Merged

Fix component registration conflicts in test environment#316
hotlong merged 5 commits intocopilot/fix-step-8-errorfrom
copilot/add-custom-action-step

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

Test failures occurred because @object-ui/fields depends on @object-ui/components, causing field widgets to overwrite basic UI components during module initialization. Form fields also lost accessibility attributes due to missing prop spreads.

Changes

Test Setup

  • Renamed vitest.setup.ts.tsx to support manual component re-registration
  • Re-register text component after all imports to override field widget collision
  • Updated vite config reference

Field Widgets

  • Added {...props} spread to 14 widgets to pass through id, aria-describedby, etc.
  • Moved prop spread before explicit props to prevent accidental overrides

Example fix:

// Before: accessibility props lost
<Input
  type="email"
  value={value}
  onChange={onChange}
  className={props.className}  // only className passed
/>

// After: all props preserved
<Input
  {...props}  // spreads id, aria-*, etc.
  type="email"
  value={value}
  onChange={onChange}
/>

Test Results

  • Dashboard nested text components: ✓ passing
  • ObjectForm field rendering: ✓ passing
  • 6 tests remain failing (pre-existing: form submission Event handling, default values, MSW integration)
Original prompt

引用: https://github.com/objectstack-ai/objectui/actions/runs/21560444982/job/62123919268#step:7:1


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 1, 2026

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

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 1, 2026 10:31am
objectui-components Ready Ready Preview, Comment Feb 1, 2026 10:31am
objectui-crm-app Ready Ready Preview, Comment Feb 1, 2026 10:31am

Request Review

Add manual re-registration of text component to override field widget

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI and others added 2 commits February 1, 2026 10:01
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Move {...props} before explicit props to allow proper overriding

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add custom action step to the workflow Fix component registration conflicts in test environment Feb 1, 2026
Copilot AI requested a review from hotlong February 1, 2026 10:16
@hotlong hotlong marked this pull request as ready for review February 1, 2026 10:16
Copilot AI review requested due to automatic review settings February 1, 2026 10:16
@hotlong hotlong merged commit 4fc895e into copilot/fix-step-8-error Feb 1, 2026
3 of 6 checks passed
Copy link
Copy Markdown
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 addresses test failures caused by component registration conflicts between @object-ui/fields and @object-ui/components. The primary issue stems from the ComponentRegistry's backward compatibility mechanism, where field widgets registered with namespace 'field' overwrite non-namespaced lookup entries for basic UI components. Additionally, field widgets were missing prop spreads that prevented accessibility attributes from being passed through.

Changes:

  • Modified test setup to manually re-register the 'text' component after module imports to restore UI namespace priority
  • Added prop spreads ({...props}) to 14 field widget components to enable proper accessibility attribute propagation
  • Correctly handled className extraction in widgets requiring class merging (CurrencyField, PasswordField, PercentField)

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/console/vitest.setup.tsx New test setup file with JSX support and manual text component re-registration
apps/console/vitest.setup.ts Deleted old test setup file (replaced by .tsx version)
apps/console/vite.config.ts Updated setupFiles reference from .ts to .tsx extension
packages/fields/src/widgets/TextField.tsx Added prop spread and removed duplicate spread at end
packages/fields/src/widgets/TextAreaField.tsx Added prop spread to pass accessibility props
packages/fields/src/widgets/EmailField.tsx Added prop spread to pass accessibility props
packages/fields/src/widgets/UrlField.tsx Added prop spread to pass accessibility props
packages/fields/src/widgets/PhoneField.tsx Added prop spread to pass accessibility props
packages/fields/src/widgets/DateField.tsx Added prop spread to pass accessibility props
packages/fields/src/widgets/DateTimeField.tsx Added prop spread to pass accessibility props
packages/fields/src/widgets/TimeField.tsx Added prop spread to pass accessibility props
packages/fields/src/widgets/NumberField.tsx Added prop spread to pass accessibility props
packages/fields/src/widgets/PasswordField.tsx Extracted className, added prop spread
packages/fields/src/widgets/PercentField.tsx Extracted className, added prop spread
packages/fields/src/widgets/CurrencyField.tsx Extracted className, added prop spread, removed duplicate
packages/fields/src/widgets/BooleanField.tsx Added prop spread but incorrect placement causes id override
packages/fields/src/widgets/SelectField.tsx Added prop spread but placed on wrong component
Comments suppressed due to low confidence (1)

packages/fields/src/widgets/SelectField.tsx:28

  • The prop spread is incorrectly placed on the Select root component. Accessibility props like id and aria-describedby should be spread on SelectTrigger, not on the Select root (which is a Radix UI Root component that doesn't accept these props). Move the prop spread from line 23 to line 28 to ensure accessibility attributes are properly applied to the trigger element.
    <Select 
      {...props}
      value={value} 
      onValueChange={onChange}
      disabled={readonly}
    >
      <SelectTrigger className={props.className}>

Comment on lines +8 to +10
// Manually re-register basic text component to override field widget
// This is necessary because @object-ui/fields has @object-ui/components as a dependency,
// so components gets loaded BEFORE fields registers its widgets, causing fields to overwrite.
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment explanation is misleading. The actual issue is that when @object-ui/fields registers components with namespace 'field', the Registry's backward compatibility mechanism (lines 97-103 in Registry.ts) also registers them without namespace, overwriting the 'ui' namespace registrations. The fix (re-registering 'text' with namespace 'ui') is correct, but the comment should accurately explain that fields' namespace:'field' registration overwrites the non-namespaced lookup entry, not that "components gets loaded BEFORE fields".

Suggested change
// Manually re-register basic text component to override field widget
// This is necessary because @object-ui/fields has @object-ui/components as a dependency,
// so components gets loaded BEFORE fields registers its widgets, causing fields to overwrite.
// Manually re-register basic text component to override the field text widget.
// When @object-ui/fields registers its widgets with namespace: 'field', the Registry's
// backward-compatibility logic also registers them without a namespace, overwriting the
// existing non-namespaced 'text' registration from @object-ui/components. We re-register
// 'text' here under the 'ui' namespace so lookups for ui:text resolve to the UI text component.

Copilot uses AI. Check for mistakes.
Comment on lines 19 to 25
<Checkbox
{...props}
id={id}
checked={!!value}
onCheckedChange={(checked) => onChange(!!checked)}
disabled={readonly}
className={props.className}
/>
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prop spread comes before the explicit id prop, which means any id passed via props will be overwritten by the locally generated id. This defeats the purpose of spreading props for accessibility. Either move {...props} after all explicit props to allow the component to use the generated id as default, or extract id from props and use it as a fallback: const finalId = props.id || config?.name || ....

Copilot uses AI. Check for mistakes.
Comment on lines 33 to 39
<Switch
{...props}
id={id}
checked={!!value}
onCheckedChange={onChange}
disabled={readonly}
className={props.className}
/>
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the checkbox variant above - the prop spread comes before the explicit id prop, which means any id passed via props will be overwritten by the locally generated id. Either move {...props} after all explicit props, or extract id from props and use it as a fallback.

Copilot uses AI. Check for mistakes.
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.

3 participants