Copilot commented on code in PR #3007:
URL: https://github.com/apache/apisix-dashboard/pull/3007#discussion_r2066836833
##########
src/components/form/TagInput.tsx:
##########
@@ -6,24 +6,34 @@ import {
} from 'react-hook-form';
import { genControllerProps } from './util';
-export type FormItemTagsInputProps<T extends FieldValues> =
- UseControllerProps<T> & TagsInputProps;
+export type FormItemTagsInputProps<
+ T extends FieldValues,
+ R
+> = UseControllerProps<T> &
+ TagsInputProps & {
+ from?: (v: R) => string;
+ to?: (v: string) => R;
+ };
-export const FormItemTagsInput = <T extends FieldValues>(
- props: FormItemTagsInputProps<T>
+export const FormItemTagsInput = <T extends FieldValues, R>(
+ props: FormItemTagsInputProps<T, R>
) => {
- const { controllerProps, restProps } = genControllerProps(props, []);
+ const {
+ controllerProps,
+ restProps: { from, to, ...restProps },
+ } = genControllerProps(props, []);
const {
field: { value, onChange: fOnChange, ...restField },
fieldState,
} = useController<T>(controllerProps);
return (
<TagsInput
- value={value}
+ value={from ? value.map(from) : value}
Review Comment:
The component transforms the value using the 'from' function for display but
passes the original value to restProps.onChange. Consider passing the
transformed value (i.e. 'val') consistently to ensure uniform handling of data.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]