mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
fixed - BUG: While changing table name/description
This commit is contained in:
@@ -12,16 +12,21 @@ export interface ITableNameProps extends IShortTextComponentProps {
|
||||
|
||||
export default function TableName({ watchedField, ...props }: ITableNameProps) {
|
||||
const {
|
||||
field: { onChange },
|
||||
field: { onChange, value },
|
||||
useFormMethods: { control },
|
||||
disabled,
|
||||
} = props;
|
||||
|
||||
const watchedValue = useWatch({ control, name: watchedField } as any);
|
||||
useEffect(() => {
|
||||
if (!disabled && typeof watchedValue === "string" && !!watchedValue)
|
||||
onChange(startCase(watchedValue));
|
||||
}, [watchedValue, disabled]);
|
||||
if (!disabled) {
|
||||
if (typeof value === "string" && value.trim() !== "") {
|
||||
onChange(value);
|
||||
} else if (typeof watchedValue === "string" && !!watchedValue) {
|
||||
onChange(startCase(watchedValue));
|
||||
}
|
||||
}
|
||||
}, [watchedValue, disabled, onChange, value]);
|
||||
|
||||
return <ShortTextComponent {...props} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user