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

feat(validation): delegate validation rendering to custom elements #432

Merged
merged 12 commits into from
Jan 17, 2018
Merged

Conversation

MaximBalaganskiy
Copy link
Collaborator

Custom elements will be able to take control over validation by defining rendering methods on a DOM element

@Thanood
Copy link
Collaborator

Thanood commented Jun 13, 2017

@MaximBalaganskiy This is a great idea! The element itself always knows best how it should be rendered. 👍

I wondered if addValidationClasses and removeValidationClasses should be with the element, too. But the element decides if these methods are called so we can keep that as a convenience.

@MaximBalaganskiy
Copy link
Collaborator Author

My initial idea was to keep everything on an element but those two methods will be called from almost every class so to follow DRY I put them on the renderer.

@Thanood
Copy link
Collaborator

Thanood commented Jun 13, 2017

Yes, I agree. If the element needs some custom behaviour it just wouldn't call addValidationClasses.

@Thanood
Copy link
Collaborator

Thanood commented Jun 21, 2017

@MaximBalaganskiy Is there anything to add/discuss here (apart from other components like select)?

@MaximBalaganskiy
Copy link
Collaborator Author

MaximBalaganskiy commented Jun 21, 2017

We've also got a date picker to convert, other than that I don't see anything else to add

Before the change mdRenderValidateResult function was called for each validation result which worked fine while validation messages were displayed.
The problem was that validation border was shown based on a presence of validation messages. It there were none - no error border.
To fix the issue an element must have all the validation results and render them all at once.
Default rendering functions are called for elements which do not provide their own. Effectively, only INPUT is supported.
@MaximBalaganskiy
Copy link
Collaborator Author

I refactored the initial solution and updated all initially supported elements

@MaximBalaganskiy MaximBalaganskiy changed the title feat(validation): call custom element's rendering methods feat(validation): delegate validation rendering to custom elements Jan 17, 2018
@MaximBalaganskiy MaximBalaganskiy merged commit 7c6c34c into aurelia-ui-toolkits:master Jan 17, 2018
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.

2 participants