Skip to content

Filter non-DOM props from field widgets to prevent React warnings#371

Merged
hotlong merged 2 commits intocopilot/update-kernel-to-latest-versionfrom
copilot/fix-build-step-error
Feb 3, 2026
Merged

Filter non-DOM props from field widgets to prevent React warnings#371
hotlong merged 2 commits intocopilot/update-kernel-to-latest-versionfrom
copilot/fix-build-step-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 3, 2026

Field widgets were spreading metadata props like inputType directly to DOM elements, causing React to warn about unrecognized DOM attributes.

Changes

Updated 11 field widget components to destructure and exclude inputType before spreading props:

Pattern applied:

// Before
return <Input {...props} type="date" value={value} onChange={...} />

// After
const { inputType, ...domProps } = props as any;
return <Input {...domProps} type="date" value={value} onChange={...} />

Affected widgets:

  • Date/time fields: DateField, DateTimeField, TimeField
  • Input fields: TextField, TextAreaField, NumberField
  • Contact fields: EmailField, PhoneField, UrlField, PasswordField
  • BooleanField

The inputType prop is form metadata used by ObjectForm for field type mapping and should not propagate to the DOM layer.

Original prompt

引用: https://github.com/objectstack-ai/objectui/actions/runs/21620386870/job/62308318117#step:9: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 3, 2026

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

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 3, 2026 7:30am
objectui-components Ready Ready Preview, Comment Feb 3, 2026 7:30am
objectui-crm-app Error Error Feb 3, 2026 7:30am

Request Review

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build step error in CI pipeline Filter non-DOM props from field widgets to prevent React warnings Feb 3, 2026
Copilot AI requested a review from hotlong February 3, 2026 07:33
@hotlong hotlong marked this pull request as ready for review February 3, 2026 07:39
Copilot AI review requested due to automatic review settings February 3, 2026 07:39
@hotlong hotlong merged commit 3bb2c36 into copilot/update-kernel-to-latest-version Feb 3, 2026
6 of 7 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 ensures that field widgets no longer leak form metadata props like inputType down to DOM elements, removing React warnings about unknown attributes while preserving existing behavior.

Changes:

  • Updated 11 field widgets to destructure inputType out of FieldWidgetProps and spread only the remaining domProps into Shadcn Input, Textarea, Checkbox, and Switch primitives.
  • Adjusted disabled handling in each widget to read from domProps.disabled instead of the original props.disabled, keeping semantics identical while avoiding new non-DOM props.
  • Added inline comments in each widget clarifying that the new destructuring is specifically to filter non-DOM props.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/fields/src/widgets/UrlField.tsx Filters out inputType before spreading props into the URL Input, preventing non-DOM metadata from reaching the DOM while preserving readonly link behavior and disabled logic.
packages/fields/src/widgets/TimeField.tsx Applies the same inputType filtering and domProps usage for the time Input, keeping readonly display untouched.
packages/fields/src/widgets/TextField.tsx Filters inputType and uses domProps for both single-line Input and multiline Textarea branches, maintaining existing handling of rows, placeholders, and readonly rendering.
packages/fields/src/widgets/TextAreaField.tsx Strips inputType before passing props to Textarea, leaving readonly rendering and max-length UI unchanged.
packages/fields/src/widgets/PhoneField.tsx Prevents inputType from reaching the phone Input DOM node while keeping tel link rendering, placeholders, and error state behavior intact.
packages/fields/src/widgets/PasswordField.tsx Filters inputType for the password Input, keeping visibility toggle and custom className handling the same while avoiding non-DOM attributes.
packages/fields/src/widgets/NumberField.tsx Excludes inputType from props passed to the number Input, preserving precision, placeholder, readonly, and numeric onChange logic.
packages/fields/src/widgets/EmailField.tsx Removes inputType from the props sent to the email Input, retaining readonly mailto link behavior and error state.
packages/fields/src/widgets/DateTimeField.tsx Filters inputType before passing props into the datetime-local Input, leaving readonly formatted display unchanged.
packages/fields/src/widgets/DateField.tsx Excludes inputType from the props for the date Input, maintaining readonly date formatting semantics.
packages/fields/src/widgets/BooleanField.tsx Strips inputType from props passed to Checkbox/Switch while preserving readonly Yes/No display and existing ID/label wiring.

Comment on lines +28 to +30
// Filter out non-DOM props
const { inputType, ...domProps } = props as any;

Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

These new inputType-filtering semantics are not currently covered by tests: the existing UrlField tests in standard-widgets.test.tsx never pass an inputType prop or assert that it is stripped before reaching the DOM, so regressions here (e.g., accidentally re-spreading inputType) would not be caught. Consider adding a test case that renders UrlField (and/or the other updated widgets) with an inputType prop and verifies that it does not appear as an attribute on the underlying DOM element (or that React does not emit warnings via a mocked console).

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +30
// Filter out non-DOM props
const { inputType, ...domProps } = props as any;

Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The inputType-filtering pattern (const { inputType, ...domProps } = props as any; followed by spreading domProps) is duplicated across several field widgets (Date, DateTime, Time, Text, TextArea, Number, Email, Phone, Url, Password, Boolean). To improve maintainability and keep this behavior consistent as the form metadata evolves, consider extracting a shared helper (e.g., in the widgets utilities) that strips non-DOM metadata props from FieldWidgetProps before they are passed to primitives, so future changes only need to be made in one place.

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