From 2f65a1da3e67fa8fa860348ca1972961cd31f060 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Tue, 18 Nov 2025 13:45:37 +1100 Subject: [PATCH] Revert form changes from #6262 Removes the components inside the formikUtils function, which was causing incorrect re-renders. Adds data-field to renderField instead, which is a far more simple change. --- ui/v2.5/src/utils/form.tsx | 141 ++++++++----------------------------- 1 file changed, 29 insertions(+), 112 deletions(-) diff --git a/ui/v2.5/src/utils/form.tsx b/ui/v2.5/src/utils/form.tsx index e11d885f8..1fef74cf2 100644 --- a/ui/v2.5/src/utils/form.tsx +++ b/ui/v2.5/src/utils/form.tsx @@ -103,14 +103,10 @@ export function formikUtils( }, }: IProps = {} ) { - type FieldName = keyof V & string; + type Field = keyof V & string; type ErrorMessage = string | undefined; - function renderFormControl( - field: FieldName, - type: string, - placeholder: string - ) { + function renderFormControl(field: Field, type: string, placeholder: string) { const formikProps = formik.getFieldProps({ name: field, type: type }); const error = formik.errors[field] as ErrorMessage; @@ -172,90 +168,38 @@ export function formikUtils( ); } - const FieldGroup: React.FC<{ - field: FieldName; - title: string; - control: React.ReactNode; - props?: IProps; - className?: string; - }> = ({ field, title, control, props, className }) => { + function renderField( + field: Field, + title: string, + control: React.ReactNode, + props?: IProps + ) { return ( - + {title} {control} ); - }; - - function renderField( - field: FieldName, - title: string, - control: React.ReactNode, - props?: IProps, - className?: string - ) { - return ( - - ); } - const InputFieldGroup: React.FC<{ - field: FieldName; - type?: string; - messageID?: string; - props?: IProps; - className?: string; - }> = ({ field, type = "text", messageID = field, props, className }) => { + function renderInputField( + field: Field, + type: string = "text", + messageID: string = field, + props?: IProps + ) { const title = intl.formatMessage({ id: messageID }); const control = renderFormControl(field, type, title); - return ( - - ); - }; - - function renderInputField( - field: FieldName, - type: string = "text", - messageID: string = field, - props?: IProps, - className?: string - ) { - return ( - - ); + return renderField(field, title, control, props); } - const SelectFieldGroup: React.FC<{ - field: FieldName; - className?: string; - entries: Map; - messageID?: string; - props?: IProps; - }> = ({ field, className, entries, messageID = field, props }) => { + function renderSelectField( + field: Field, + entries: Map, + messageID: string = field, + props?: IProps + ) { const formikProps = formik.getFieldProps(field); let { value } = formikProps; @@ -280,35 +224,11 @@ export function formikUtils( ); - return ( - - ); - }; - - function renderSelectField( - field: FieldName, - entries: Map, - messageID: string = field, - props?: IProps - ) { - return ( - - ); + return renderField(field, title, control, props); } function renderDateField( - field: FieldName, + field: Field, messageID: string = field, props?: IProps ) { @@ -328,7 +248,7 @@ export function formikUtils( } function renderDurationField( - field: FieldName, + field: Field, messageID: string = field, props?: IProps ) { @@ -348,7 +268,7 @@ export function formikUtils( } function renderRatingField( - field: FieldName, + field: Field, messageID: string = field, props?: IProps ) { @@ -389,7 +309,7 @@ export function formikUtils( } function renderStringListField( - field: FieldName, + field: Field, messageID: string = field, props?: IProps ) { @@ -412,7 +332,7 @@ export function formikUtils( } function renderURLListField( - field: FieldName, + field: Field, onScrapeClick?: (url: string) => void, urlScrapable?: (url: string) => boolean, messageID: string = field, @@ -439,7 +359,7 @@ export function formikUtils( } function renderStashIDsField( - field: FieldName, + field: Field, linkType: LinkType, messageID: string = field, props?: IProps @@ -485,11 +405,8 @@ export function formikUtils( return { renderFormControl, renderField, - FieldGroup, renderInputField, - InputFieldGroup, renderSelectField, - SelectFieldGroup, renderDateField, renderDurationField, renderRatingField,