opened
jlongster
username_0
Fixes #281. 

As I dug into this I realized that it would be nicer to consolidate the code for scrolling to an item so it behaves exactly the same whether or not you are controlling the prop. This will reduce bugs between those use cases.

The way to do this is to always scroll within `componentDidUpdate`. The only problem is that this makes it harder to control scrolling; my first attempt added an option to `setHighlightedIndex` to avoid scrolling, and since that's called directly from `onMouseEvent` we can pass that information. But in `componentDidUpdate` we have no idea why it's changing. However this is always the case in the controlled prop scenario anyway, so we have to accept it.

The only solution is an ugly setTimeout which tells the system to not scroll it at all. This nicely fixes the problem entirely; it'll never scroll it if you are moving the cursor around or scrolling yourself and makes it feel a lot better. Note that this also changes the uncontrolled prop scenario: if you hover over an element at the bottom of the list, **it will no longer scroll down** to show it fully in view. This is better behavior in my opinion though as I'd never expect it to move around under me just by hovering.

This does not fix #240, as it's a different issue caused by a similar `onMouseEnter` event. A similar fix could be adopted there where it sets a timeout to tell the system to avoid any `onMouseEnter` events after key up/down.

**Checklist**:

* [ ] Documentation NA
* [x] Tests
* [x] Ready to be merged
      <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
* [x] Added myself to contributors table
Consolidate scrolling of the list when highlighted index changes and never scroll from a `onMouseEnter` event (fixes #281)
issue
created
kentcdodds
username_1
Ok! I've written a test for it and I'm much happier with this now that I can see the test. Makes a lot of sense. Thank you very much for the contribution :clap:
comment
created
kentcdodds
username_1
Thanks so much for your help @username_0! I've added you as a collaborator on the project. Please make sure that you review the `other/MAINTAINING.md` and `CONTRIBUTING.md` files (specifically the bit about the commit messages and the git hooks) and familiarize yourself with the code of conduct (we're using [the contributor covenant](http://contributor-covenant.org/)). You might also want to [watch the repo](https://help.github.com/articles/watching-repositories/) to be notified when someone files an issue/PR. Please continue to make PRs as you feel the need (you can make your branches directly on the repo rather than your fork if you want). Thanks! And welcome to the team :)
comment