Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(select): Position incorrect if selection scrolled. #6354

Closed
wants to merge 1 commit into from

Conversation

topherfangio
Copy link
Contributor

If the currently selected object scrolled into view because it was further down in the list, the position of the menu was incorrect upon opening because the scrollTop of the contentNode was always 0 due to the ARIA changes which set it to display: none upon closing.

Fix by modifying the display to block when we run the isScrollable check and back afterward (usually display: none but we account for other options).

Also fixes a slight 2px positioning issue which made the menu not perfectly line up with the underlying selection.

Fixes #6190.

@topherfangio topherfangio added the needs: review This PR is waiting on review from the team label Dec 16, 2015
@topherfangio topherfangio added this to the 1.01 milestone Dec 16, 2015
@topherfangio topherfangio force-pushed the team/topher/fix-select-position-6190 branch from d488e4b to c69e486 Compare December 16, 2015 23:02
@topherfangio
Copy link
Contributor Author

@rschmukler This is ready for review.

@ThomasBurleson If he happens to not be around, this is ready for review and Naomi would like it in the next release.

var oldDisplay = element[0].style.display;

// Set the element's display to block so that this calculation is correct
element[0].style.display = 'block';
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be in a try { } finally { }.

@rschmukler
Copy link
Contributor

LGTM

@@ -1276,7 +1276,7 @@ function SelectProvider($$interimElementProvider) {
* Calculate the
*/
function calculateMenuPositions(scope, element, opts) {
var
var
Copy link
Member

Choose a reason for hiding this comment

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

Can you make all those with var? or without it cause there are var deceleration right after..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note how all of the following variable declarations have a comma , at the end except the last one, which has a semi-colon. The semi-colon is the stop of the var statement basically, so yes, you can do it :-)

Copy link
Member

Choose a reason for hiding this comment

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

It wasn't a question.. i know you can aggregate var declarations into one.

I was asking you to separate it or make the following var declarations (after the semi-colon) aggregated too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, sorry, I see now! I originally had the style code above/below this line which is why I separated it, but I can indeed move those back together now.

@topherfangio topherfangio force-pushed the team/topher/fix-select-position-6190 branch from c69e486 to b8e92d7 Compare December 17, 2015 18:05
@topherfangio
Copy link
Contributor Author

@ThomasBurleson Updated with your suggestions. Ready for review/merging.

If the currently selected object scrolled into view because it
was further down in the list, the position of the menu was
incorrect upon opening because the `scrollTop` of the `contentNode`
was always `0` due to the ARIA changes which set it to
`display: none` upon closing.

Fix by modifying the display to `block` when we run the `isScrollable`
check and back afterward (usually `display: none` but we account for
other options).

Also fixes a slight `2px` positioning issue which made the menu not
perfectly line up with the underlying selection.

Fixes #6190.
@topherfangio topherfangio force-pushed the team/topher/fix-select-position-6190 branch from b8e92d7 to 81acf67 Compare December 17, 2015 20:42
// Nothing to do
}
return isScrollable;
}
Copy link
Member

Choose a reason for hiding this comment

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

I unit test would be nice to have, but I want to get this in 1.0.1, so it can be added later.

@ThomasBurleson ThomasBurleson removed the needs: review This PR is waiting on review from the team label Dec 17, 2015
topherfangio added a commit that referenced this pull request Dec 18, 2015
This is a simple unit test to ensure the fix from
PR #6354 works as expected.
topherfangio added a commit that referenced this pull request Dec 21, 2015
This is a simple unit test to ensure the fix from
PR #6354 works as expected.
@topherfangio topherfangio deleted the team/topher/fix-select-position-6190 branch December 21, 2015 20:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

md-select misplaced
5 participants