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

Prevent Scroll to First Selection on Select/Unselect #4869

Closed

Conversation

MicahBrown
Copy link

Resolves issue for multiselects using closeOnSelect: false that caused the list of results to scroll to the first selection after each select/unselect

This pull request includes a

  • Bug fix
  • New feature
  • Translation

The following changes were made

  • Removed behavior for scrolling to first selection after each selection/unselection

If this is related to an existing ticket, include a link to it as well.
#1513

Resolves issue for multiselects using `closeOnSelect: false` that caused the list of results to scroll to the first selection after each select/unselect
@lvmajor
Copy link

lvmajor commented Apr 20, 2017

Just a suggestion, instead of commenting out the feature for the highlightFirstItem prototype, maybe you could simply comment the line where it highlights the first item on select (line 277 in your version of the code now)?
This way when closing/reopening the selectbox, you get the first item in sight, which IMO should be the case. What is your opinion about that?

@MicahBrown
Copy link
Author

@os1r1s110 I revised it.

@alexweissman
Copy link
Contributor

alexweissman commented Sep 25, 2017

@MicahBrown is there any indication in the commit history as to why self.highlightFirstItem(); was added in the first place? I want to be sure that removing these lines doesn't cause a regression in other features. See #4417 for an alternate proposal.

A test or two to assert the behavior that this patch fixes, would also be appreciated.

@MicahBrown
Copy link
Author

@alexweissman Unfortunately, I don't know if I'll have time to write any tests since I'm very busy now. I did do a quick look-through on the commit history and found that the self.highlightFirstItem() was first introduced in this commit: e897d00 (it's been renamed from self.focusFirstItem()). When it was first introduced, it didn't have the this.ensureHighlightVisible() call, which is what's causing the issue now and bringing the first item into view. I don't see why we would want self.highlightFirstItem() called on the select or unselect triggers, so that's why I took it out of those triggers and left the results:all one. Hopefully that helps!

Also, we've been using my change in production for a few months now and haven't noticed any regressions. I know that doesn't cover all cases, but thought I'd mention it.

@alexweissman
Copy link
Contributor

No problem, and thanks for getting back to me so quickly.

It would appear that highlightFirstItem was added for the infinite scroll (pagination) feature, as per @jgbishop's comment:

I'd argue that the "highlight first item" feature should be adjusted to work either only in the infinite scroll case (while the popup is open and the user is scrolling), or via a user-set option.

@alexweissman
Copy link
Contributor

Please see #4417 (comment) to understand why we cannot simply remove the self.highlightFirstItem() calls entirely. We need to add some logic so that self.highlightFirstItem() is only called when infinite scroll (pagination) is used.

@alexweissman
Copy link
Contributor

I notice that #4625 also adds some conditional logic for scrolling to the first item, to handle some other use cases.

It almost seems like maybe "scroll-after-select" should be a configurable option?

@alexweissman
Copy link
Contributor

Please continue the discussion for this feature in #5150.

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

Successfully merging this pull request may close these issues.

None yet

3 participants