-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Showing selected option on top view #4305
Comments
You can add an const selectRef = useRef();
const onMenuOpen = () => {
setTimeout(() => {
const { focusedOptionRef } = selectRef.current.select;
focusedOptionRef && focusedOptionRef.scrollIntoView();
}, 1);
};
return <Select ref={selectRef} onMenuOption={onMenuOption} /> Demo: codesandbox A couple notes about this...
In any case, this should resolve your use case. If you have any further questions, happy to discuss. |
Is there already a better recommended way to achieve this? I would also like to display the selected item as the first option, isn't there a way to invoke the scrollIntoView({ block: "start", inline: "start" }) |
Is there any way to stop sudden jump in the changing of it being moved to the top..? |
Hello,
I am using the latest version of react-select. I am seeing default behavior to show the selected option at the buttom of the menu view like this
Is there any way to change so that when the menu is open, "Cape Verde" shows where the "Brunei Darussalam" shows in the picture?
Thanks
The text was updated successfully, but these errors were encountered: