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

Fix for Adapt.scrollTo 'jump' bug #1400

Merged
merged 3 commits into from
Feb 10, 2017

Conversation

chris-steele
Copy link
Contributor

@chris-steele chris-steele commented Jan 27, 2017

This fix addresses an issue when navigating to components via page-level progress in certain circumstances. If the component description aria-label is aligned to the top of the component div (as happens in certain art directions), Adapt.scrollTo would centre the top of the component within the viewport rather than at the top of the viewport. N.B. this issue is normally only replicable when accessibility has been activated.

@@ -106,9 +106,11 @@ define([
}

var navigationHeight = $(".navigation").outerHeight();
// prevent scroll issue when component description aria-label coincident with top of component
var ariaLabelBuffer = $(selector.is('.component')) ? 5 : 0;
Copy link
Member

Choose a reason for hiding this comment

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

5 is a magic number here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know it's not ideal and we have other magic numbers with some of the deferred calls, particularly in the a11y code. There is an alternative, which I discussed with @kirsty-hames and that is to place this 5px offset in the theme to shove the aria-label down. I preferred the code method as it means we don't need to make this change in multiple themes.

@brian-learningpool, @kirsty-hames, @tomgreenfield is the consensus that this is better fixed in the theme(s)?

Copy link
Contributor

@tomgreenfield tomgreenfield Jan 30, 2017

Choose a reason for hiding this comment

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

If this offset is going to handled here, I'd prefer a more programmatical approach like below:

var $element = $(selector);
var offsetTop = -navigationHeight;

if (Adapt.config.get('_accessibility')._isActive &&
    $element.hasClass('component')) {
    offsetTop -= $element.find('.aria-label').height() || 0;
}

Am I right in thinking it's only an issue in Firefox? If it's such a small use case that it's only when accessibility is active and it's a component and in one browser and in a certain style of art direction, then it may make more sense to fix in the theme.

Copy link
Contributor Author

@chris-steele chris-steele Jan 30, 2017

Choose a reason for hiding this comment

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

Present in IE*, Edge and Firefox. The above could work (amending to .aria-label:first), though I'd have to test the reported height (1px and 3px I think, respectively) would be sufficient.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, well the height() method already uses the first element if multiple are found. Haven't yet tested in IE8 or Edge but could have a gander later if you like.

Copy link
Contributor

@tomgreenfield tomgreenfield Jan 31, 2017

Choose a reason for hiding this comment

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

I can't actually replicate the original issue in IE8, while the above code fixes it for me in Firefox & Edge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's unusual, but it seems IE8 doesn't have this problem, just IE9 and above!

@moloko moloko merged commit 46c1ddf into adaptlearning:master Feb 10, 2017
@moloko
Copy link
Contributor

moloko commented Feb 10, 2017

#1422

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.

5 participants