Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: expose setFieldTouched #50

Merged
merged 5 commits into from
Jan 3, 2024
Merged

Conversation

reslear
Copy link
Contributor

@reslear reslear commented Nov 26, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have read the Contributing Guidelines.
  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@@ -138,6 +138,7 @@ export interface UseFormReturn<Values extends FormValues> {
setFieldValue: UseFormSetFieldValue<Values>;
setErrors: (errors: FormErrors<Values>) => void;
setFieldError: UseFormSetFieldError<Values>;
setFieldTouched: (name: Values, touched?: boolean) => void;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type definition here seems incorrect. See UseFormSetFieldError<Values> for details on this section.

export type UseFormSetFieldError<Values extends FormValues> = <
Name extends Path<Values>,
>(
name: Name,
error: FormErrors<PathValue<Values, Name>> | string | string[],
) => void;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected but I don't know if it is necessary to return errors :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. Regarding returning errors, do you think we should be consistent with setFieldValue, setFieldError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the one hand, it's easier, on the other hand we don't need the extra, so I suggest we keep it that way for now (i.e. forever).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand what you mean. Do you think something like below is better?

export type UseFormSetFieldTouched<Values extends FormValues> = <
  Name extends Path<Values>,
>(
  name: Name,
  touched: boolean,
) => void

Because it will be consistent with other functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes maybe better, could have corrected it as you like ?)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your assistance in clarifying the issue. Considering the situation, I believe it might be more appropriate to return void for the time being.

@@ -114,6 +114,13 @@ export type UseFormSetFieldError<Values extends FormValues> = <
error: FormErrors<PathValue<Values, Name>> | string | string[],
) => void;

export type UseFormsSetFieldTouched<Values extends FormValues> = <
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use UseFormSetFieldTouched instead of UseFormSetsFieldTouched

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Mini-ghost Mini-ghost merged commit 83cb5fe into Mini-ghost:main Jan 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants