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

fix(core): remove mount validation on touch #726

Merged
merged 5 commits into from
Nov 4, 2024

Conversation

Balastrong
Copy link
Member

@Balastrong Balastrong commented May 30, 2024

This PR closes #689

A few considerations:

  1. When should we remove the errors?
    My proposal would be to remove each field individually when gets touched and the form as soon as a field is touched.
    As long as a field is not touched, it keeps the mount errors.

  2. Should we be able to submit a form with onMount errors?
    I'd say no, but currently if state.submissionAttempts === 0 && !isTouched we have canSubmit: true
    Adding && !hasOnMountError also aims to fix the unwanted behavior described in canSubmit is always true on first render of form #723

  3. We might want to explicitly explain in the docs how we intend onMount to behave
    I'm happy to improve the docs in this PR if we decide to go through with the proposed behavior

  4. Bonus
    The amount of eslint disable on form.errorsMap makes me wonder if we should consider it as optional in first place, but that's maybe another topic.

Copy link

nx-cloud bot commented May 30, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit f25c26b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@brandonryan
Copy link

brandonryan commented Oct 29, 2024

This really tripped our team up. We expected that if we specify onMount + onChange validators then when the field is "changed" it would clear the onMount error. I think clearing the mount error on change / blur is probably a reasonable way to address it.

Copy link

pkg-pr-new bot commented Nov 4, 2024

Open in Stackblitz

More templates

@tanstack/angular-form

pnpm add https://pkg.pr.new/@tanstack/angular-form@726

@tanstack/form-core

pnpm add https://pkg.pr.new/@tanstack/form-core@726

@tanstack/lit-form

pnpm add https://pkg.pr.new/@tanstack/lit-form@726

@tanstack/react-form

pnpm add https://pkg.pr.new/@tanstack/react-form@726

@tanstack/solid-form

pnpm add https://pkg.pr.new/@tanstack/solid-form@726

@tanstack/valibot-form-adapter

pnpm add https://pkg.pr.new/@tanstack/valibot-form-adapter@726

@tanstack/vue-form

pnpm add https://pkg.pr.new/@tanstack/vue-form@726

@tanstack/yup-form-adapter

pnpm add https://pkg.pr.new/@tanstack/yup-form-adapter@726

@tanstack/zod-form-adapter

pnpm add https://pkg.pr.new/@tanstack/zod-form-adapter@726

commit: f25c26b

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.50%. Comparing base (5473bb8) to head (f25c26b).
Report is 154 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #726      +/-   ##
==========================================
- Coverage   91.55%   88.50%   -3.05%     
==========================================
  Files          21       26       +5     
  Lines         900     1079     +179     
  Branches      206      267      +61     
==========================================
+ Hits          824      955     +131     
- Misses         71      115      +44     
- Partials        5        9       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Balastrong Balastrong merged commit dbaf283 into TanStack:main Nov 4, 2024
6 of 7 checks passed
@Balastrong Balastrong deleted the fix/on-mount-validation branch November 4, 2024 20:28
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.

onMount Error is not revalidated when the user changes the input
2 participants