JedWatson / react-select

The Select Component for React.js
https://react-select.com/
MIT License
27.62k stars 4.12k forks source link

Is there an on focused option change event #4544

Closed dtaub closed 3 years ago

dtaub commented 3 years ago

Hey, first of all obligatory thanks for all the work on this component.

I implemented a custom MenuList component in order to support virtual scrolling (using react-virtuoso). Something I noticed, however, is that when using the arrow keys to change the selected option in the menu, the menu no longer scrolls the selected option into view. This is understandable given the scrollable container is custom so I was trying to reimplement the behavior of scrolling the focused option into view, but I can't find any event or any way to know that.

I expected there would be some event for when the focused option changed but I don't see one. Digging through the code a bit, I don't see any event getting fired when the focused option changes either. Is there a way to listen for the focused option that I'm missing?

ebonow commented 3 years ago

Greetings @dtaub,

Given that this appears to be an implementation question and not a library issue, I will convert this to a discussion.

To answer your question, the focusedOption is now being returned to the MenuList component as a prop as of version 4.3.

Do you have a codesandbox that can be looked at for troubleshooting?