-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(uiSelectCtrl): scroll to dropdown position on dropdown open #2034
base: master
Are you sure you want to change the base?
fix(uiSelectCtrl): scroll to dropdown position on dropdown open #2034
Conversation
Can you update your branch to resolve conflicts? |
I'll give it a go tomorrow |
Right on, thanks! |
…ogic to private function Extracted: - method: _displayDropdown(initSearchValue, avoidReset) -> handle opening - method: _canAnimate(element) - method: _animateDropdown(searchInput, initSearchValue, container)
When ui-select is configured with `resetSearchInput: false` `ctrl.activeIndex` is not calculated when `ctrl.activate()` is invoked Opening an ui-select control with preselected model doesn't trigger active index update/reset and so the container is scroll the the element with 0 `ctrl.activeIndex` initial value (check `_ensureHighlightVisible()`)
Extracted repeating logic that focuses the search input after the dropdown is clicked Performed with $timeout so any digest or animation logic is waited for
…unction with $animate The function `_ensureHighlightVisible()` that scrolls to the active (highlighted) element is never invoked at the end of the animation, when animation is used The logic that handles non animation opening is a bit different in that it scrolls to the highlighted element Updated the animation handler to perform similarly
This sets proper element size during testing And doesn't break the rest of the test Tests for scroll position depend on these styles
…urn promise The promise is resolved when the animation is switched off (unsubscribed) This extracts the additional responsibility to call focus/scroll the active element at the end of the animation
4191236
to
e6ba734
Compare
Ready This PR changes uiSelectCtrl's |
Whoa! I no longer have permissions to merge. @Jefiozie can you review/merge this PR? |
To release a new version, please follow these steps:
All of this is supposed to be encapsulated in a single gulp command |
Is this still merged? Currently this doesn't work anymore, and it doesn't scroll to the selected option. |
Related to issue #976 and pull request #1742
As suggested in the above references - a couple of helper function were extracted
Updated the animation handling to use $q promise and resolve when the animation is unsubscribed
Then the caller triggers the actual focusing/scrolling logic so it stays out of the animation handler context
If it's not desired to use promise there the last commit can just be reverted/removed
Added tests about the scrolling functionality, the one that handles the animation callback is a bit tricky and can be updated, I haven't used $animate and written tests for it before
Had to include the
select.css
tokarma.config
in order to have proper sizes for theelements that are tested otherwise container.scrollTop is always 0
This did not alter execution time or results for other tests