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

added null check to avoid exception when element is hidden #244

Merged
merged 2 commits into from Oct 10, 2016

Conversation

mfmc112
Copy link

@mfmc112 mfmc112 commented Oct 5, 2016

This is to fix the issue when an error message "top" was displaying. The last fix needed a validation to check if the offset is returning anything so the top would returned.

@@ -86,7 +86,9 @@
var $target = $(form).find(selector);
$timeout(function() {
// scroll to offset top of first error minus the offset of the navbars
$('body, html').animate({scrollTop: $target.offset().top - offset}, 'fast');
if ($target !== undefined && $target.offset() !== undefined ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move the check outside the timeout? if possible just check for truthy:

if ($target && $target.offset()) {
 // code
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Done.

@robmcguinness robmcguinness merged commit dbf68ef into master Oct 10, 2016
@robmcguinness robmcguinness deleted the bugfix/offset-undefined-on-hidden-element branch November 21, 2016 14:07
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.

None yet

2 participants