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(Form): invalid errors when using clear by path #1165

Merged

Conversation

johnpuaoi
Copy link
Contributor

πŸ”— Linked issue

Issue #1164

❓ 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)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The current implementation of the clear function would set the errors ref to the result of a filter on the errors ref. However the test was checking if the errors path was equal to the path passed to the clear function. This results in all other form errors being cleared except for the error(s) that have the specified path, which is opposite of the docs say: "Clears form errors associated with a specific path. If no path is provided, clears all form errors.".

So I just set the filters test to filter all errors that has a path not equal to the path passed in to the clear function.

clear (path?: string) {
        if (path) {
          errors.value = errors.value.filter((err) => err.path !== path)
        } else {
          errors.value = []
        }
      }

Resolves #1164

πŸ“ Checklist

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

Copy link

vercel bot commented Dec 27, 2023

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
ui βœ… Ready (Inspect) Visit Preview Dec 29, 2023 0:14am

Copy link
Collaborator

@romhml romhml left a comment

Choose a reason for hiding this comment

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

Thanks @johnpuaoi!

@benjamincanac benjamincanac changed the title fix(Form): Correct error clearing function to remove errors by path fix(Form): invalid errors when using clear by path Jan 2, 2024
@benjamincanac benjamincanac merged commit 97a3975 into nuxt:dev Jan 2, 2024
2 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.

form clear function does not clear errors with the passed in path
3 participants