From 14d2d5be801d1475c84a6dca2d8a33132c8459c2 Mon Sep 17 00:00:00 2001 From: erikras-gilfoyle-agent Date: Fri, 13 Feb 2026 10:20:47 +0100 Subject: [PATCH] fix: Support input prop override in Field component Fixes #1048 In v6.x, users could pass an `input` prop to override or extend the field's input properties. This broke in v7.0.0 because the `input` prop wasn't being destructured and merged with `field.input`. Changes: - Destructure `input` prop from Field component props - Merge provided `input` with `field.input` (user props take precedence) - Add `input?: Partial` to FieldProps interface - Apply merged input to all render paths (children function, string component, custom component) This restores v6.x behavior while maintaining v7.0.0 improvements. Example usage: ```tsx ``` --- src/Field.tsx | 12 +++++++++--- src/types.ts | 1 + typescript/index.d.ts | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Field.tsx b/src/Field.tsx index ff034f9..e72448f 100644 --- a/src/Field.tsx +++ b/src/Field.tsx @@ -19,6 +19,7 @@ function FieldComponent< format, formatOnBlur, initialValue, + input, isEqual, multiple, name, @@ -52,17 +53,22 @@ function FieldComponent< value, }); + // Merge provided input prop with field.input + const mergedField = input + ? { ...field, input: { ...field.input, ...input } } + : field; + if (typeof children === "function") { return ( children as ( props: FieldRenderProps & typeof rest, ) => React.ReactNode - )({ ...field, ...rest }); + )({ ...mergedField, ...rest }); } if (typeof component === "string") { // ignore meta, combine input with any other props - const inputProps = { ...field.input }; + const inputProps = { ...mergedField.input }; // Ensure multiple select has array value if ( @@ -86,7 +92,7 @@ function FieldComponent< } return renderComponent( - { children, component, ...rest, ...field }, + { children, component, ...rest, ...mergedField }, {}, `Field(${name})`, ); diff --git a/src/types.ts b/src/types.ts index e09c96f..5cee6c8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -126,6 +126,7 @@ export interface FieldProps< Omit>, "children"> { name: string; children?: RenderableProps>["children"]; + input?: Partial>; // Allow overriding input props [key: string]: any; // Allow additional props for HTML elements } diff --git a/typescript/index.d.ts b/typescript/index.d.ts index fb81265..1f37ce5 100644 --- a/typescript/index.d.ts +++ b/typescript/index.d.ts @@ -125,6 +125,7 @@ export interface FieldProps< Omit>, "children"> { name: string; children?: RenderableProps>["children"]; + input?: Partial>; [key: string]: any; }