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

form clear function does not clear errors with the passed in path #1164

Closed
johnpuaoi opened this issue Dec 27, 2023 · 0 comments · Fixed by #1165
Closed

form clear function does not clear errors with the passed in path #1164

johnpuaoi opened this issue Dec 27, 2023 · 0 comments · Fixed by #1165
Labels
bug Something isn't working

Comments

@johnpuaoi
Copy link
Contributor

Environment

  • Operating System: Windows_NT
  • Node Version: v21.0.0
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: npm@10.2.0
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Version

2.11.1

Reproduction

https://stackblitz.com/edit/nuxt-ui-vq8wpj?file=components%2FTest.vue

Description

The clear function for the Form component should clear errors for a specific path when passing the path arg, instead it clears all other errors and keeps the errors associated with that path.

This is the function in the form component.

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

I think it should be a simple change to:

clear (path?: string) {
        if (path) {
          // Set errors to array of errors without the specified path.
          errors.value = errors.value.filter((err) => err.path !== path)
        } else {
          errors.value = []
        }
      }

Will submit a PR.

Additional context

No response

Logs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant