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

scrollToEnd is fired when typeahead is present before reaching scroll end #1018

Closed
neil-coutinho opened this issue Jan 7, 2019 · 4 comments

Comments

@neil-coutinho
Copy link

Describe the bug

If you have a typeahead present the scrollToEnd is fired even before you reach the bottom of the options.

Reproducbile example
StackBlitz which reproduces described behaviour

To Reproduce
Steps to reproduce the behavior (if example is not provided):

  1. Open the dropdown (It loads with a set of options)

  2. Scroll down to the 2nd option

  3. Now type something in the search box, you will see that after the typeahead subject emits a value the scrollToEnd event is fired as well

Expected behavior
ScrollToEnd should only fire if the user has reached the end of the list. Not when the list is reset or updated

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [Mac OS]
  • Browser [Chrome]
@anjmao
Copy link
Member

anjmao commented Jan 16, 2019

@neil-coutinho Thanks for a good catch. This happens because after you scrolled to to second item ng-select checks if last item is reached and as you later type in search and only few items are visible it fires that event. Probably the simplest fix would be to reset fire to end flag if items changed https://github.com/ng-select/ng-select/blob/master/src/ng-select/ng-dropdown-panel.component.ts#L122

@janstadt
Copy link

We're seeing that with this change we're not seeing the event being fired due to a rounding issue.
MicrosoftTeams-image (1)

Thoughts on rounding up here?

if (ceil(scrollTop + this._dropdown.clientHeight) >= padding.clientHeight) { ... }

@nrcdmovliaiko
Copy link

any updates?

@chzeeshansaleem
Copy link

i have faced this same issue how to solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants