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

v8 - use ng-hide in validation directive #9028

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -11,24 +11,25 @@
link: function (scope, element, attr, ctrl) {

var formMgr = ctrl.length > 1 ? ctrl[1] : null;
const hiddenClass = 'ng-hide';

//We can either get the form submitted status by the parent directive valFormManager
//or we can check upwards in the DOM for the css class... lets try both :)
//The initial hidden state can't always be hidden because when we switch variants in the content editor we cannot
//reset the status.
var submitted = element.closest(".show-validation").length > 0 || (formMgr && formMgr.showValidation);
if (!submitted) {
element.hide();
element[0].classList.add(hiddenClass);
}

var unsubscribe = [];

unsubscribe.push(scope.$on("formSubmitting", function (ev, args) {
element.show();
element[0].classList.remove(hiddenClass);
}));

unsubscribe.push(scope.$on("formSubmitted", function (ev, args) {
element.hide();
element[0].classList.add(hiddenClass);
}));

//no isolate scope to listen to element destroy
Expand Down