AU2 validation in conditionally rendered component

I have an issue with validation controller reset on component detaching.

Have conditionally rendered component with @bindable model and validation rules on that model.

Validation works perfectly after first component rendering, but when it gets detached and attached again validation results are not showing when validate() is called.
I setup validation rules on attached after the model is bound, and validation rules and validation controller reset on detaching…

Hi @StefanNj! Thank you for reporting this issue. I can reproduce the issue and created a GH issue for this: Validation in conditionally rendered component · Issue #2025 · aurelia/aurelia · GitHub. I intend to push a fix in coming days.

3 Likes

@StefanNj A fix has been merged. Try the next release :slight_smile:

2 Likes

@Sayan751 Thanks! Fix will be in beta.22?

Yes, that is correct.

@Sayan751 One more bug I noticed after the beta.18 update.

validation-container doesn’t remove the DefaultKeyPrefix.
image
image
DefaultKeyPrefix=“validation”, and the prefix was not removed after displaying the validation message.

It seems that you are using a different key. Is it possible that the property is Location and the i18n key, as seen in your screenshot, is location? If not, then please share a reproduction.

Here is the reproduction. I can’t even override the default validation message.

Thanks for the reproduction @StefanNj. It seems like a regression from the recent work done for the new state rule. I will take care of it soon.

1 Like

@StefanNj The fix is now merged.

2 Likes

Thanks! I will try in the next release.

1 Like