Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function FieldComponent<
format,
formatOnBlur,
initialValue,
input,
isEqual,
multiple,
name,
Expand Down Expand Up @@ -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<FieldValue, T> & 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 (
Expand All @@ -86,7 +92,7 @@ function FieldComponent<
}

return renderComponent(
{ children, component, ...rest, ...field },
{ children, component, ...rest, ...mergedField },
{},
`Field(${name})`,
);
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export interface FieldProps<
Omit<RenderableProps<FieldRenderProps<FieldValue, T>>, "children"> {
name: string;
children?: RenderableProps<FieldRenderProps<FieldValue, T>>["children"];
input?: Partial<FieldInputProps<FieldValue, T>>; // Allow overriding input props
[key: string]: any; // Allow additional props for HTML elements
}

Expand Down
1 change: 1 addition & 0 deletions typescript/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export interface FieldProps<
Omit<RenderableProps<FieldRenderProps<FieldValue, T>>, "children"> {
name: string;
children?: RenderableProps<FieldRenderProps<FieldValue, T>>["children"];
input?: Partial<FieldInputProps<FieldValue, T>>;
[key: string]: any;
}

Expand Down
Loading