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

Using watch, validation message spans aren't added to the register if new fields are added to form #70

Closed
geoffbeaumont opened this issue Sep 11, 2023 · 5 comments · Fixed by #65

Comments

@geoffbeaumont
Copy link

The problem is that the root passed to ValidationService.prototype.scanMessages = function (root, remove) is the new element detected, not the form. scanMessages checks for a form and registers the message under the form, but it only walks down the DOM, so if the new element is within the form no form is found and the message is not registered.

In my case I can work round this by adding form attributes to the message spans before adding them to the DOM, but that probably isn't always going to be possible.

Probably need to walk up the DOM until finding a form if the root isn't a form and doesn't contain any forms. Only if that doesn't find a form (in which case the new element detected wasn't relevant) should the function return without searching for message spans to register.

@dahlbyk
Copy link
Collaborator

dahlbyk commented Sep 11, 2023

If I'm understanding correctly, this is what #65 is meant to solve. You might try that branch and see if it resolves your issue?

@geoffbeaumont
Copy link
Author

@dahlbyk Yes, that's the exact scenario I have - I'll test the code from #65, but it looks to me like it'll fix it without any side effects beyond a tiny performance impact.

@geoffbeaumont
Copy link
Author

@dahlbyk I can confirm that #65 fixes this for me. I'm not seeing any side effects.

@dahlbyk
Copy link
Collaborator

dahlbyk commented Sep 13, 2023

Just need @haacked to :shipit:

@haacked
Copy link
Owner

haacked commented Sep 13, 2023

Just published! https://www.npmjs.com/package/aspnet-client-validation/v/0.8.16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants