-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(input): remove unnecessary warnings when ng-messages not provided #11352
fix(input): remove unnecessary warnings when ng-messages not provided #11352
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for investigating this and submitting a PR! I just had a couple comments related to performance.
src/components/input/input.js
Outdated
$log.warn('mdInput messages show animation called on invalid messages element: ', element); | ||
done(); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can understand removing the warning, but this seems to also be removing the done();
call and the early return
. I think that we still want those things for performance and correctness. We don't need to trigger the animations if there are no messages to animate in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, thanks. I will implement those changes.
As the animators
array is empty it should not cause any performance issues. However for the correctness it makes sense to handle it here rather than depend on the behaviour of the called all
function.
I will fix it as soon as possible.
src/components/input/input.js
Outdated
$log.warn('mdInput messages hide animation called on invalid messages element: ', element); | ||
done(); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. We don't need to animate the messages out if there are no messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making those updates. Can you please remove those two extra whitespaces and squash your commits?
src/components/input/input.js
Outdated
@@ -1007,12 +1005,11 @@ function ngMessageAnimation($$AnimateRunner, $animateCss, $mdUtil, $log) { | |||
function showInputMessages(element, done) { | |||
var animators = [], animator; | |||
var messages = getMessagesElement(element); | |||
var children = messages.children(); | |||
var children = messages.children(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove the added whitespace at the end of this line?
src/components/input/input.js
Outdated
@@ -1027,12 +1024,11 @@ function showInputMessages(element, done) { | |||
function hideInputMessages(element, done) { | |||
var animators = [], animator; | |||
var messages = getMessagesElement(element); | |||
var children = messages.children(); | |||
var children = messages.children(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove the added whitespace at the end of this line?
There is no requirement to include the messages in case of an error. Highlighting the field can be enough. Fixes angular#10461
3fcd61f
to
f7d812e
Compare
@Splaktar just wanted to highlight that I squashed the commits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There is no requirement to include the messages in case of an error.
Highlighting the field can be enough.
Fixes #10461
PR Checklist
Please check that your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
At the moment warning are displayed in the console when ng-messages are not specified for the input field.
Issue Number:
Relates to #10461
Relates to #9468
What is the new behavior?
The warnings are not generated as it is not required to include the error messages.
The original fix for #9468 is still in place. The other changes introduced together with that fix were removed.
Does this PR introduce a breaking change?
Other information