react-select icon indicating copy to clipboard operation
react-select copied to clipboard

Multivalue menu focuses to first option on enter

Open chrispobs opened this issue 2 years ago • 3 comments
trafficstars

Version react-select: 5.2.1

Issue is when I have enough options for the menu to scroll. The Menu works fine if i use the mouse but when i use my keyboard and navigate down and select by pressing Enter key. The focus of the option goes to first option. Is there a way to prevent this?

chrispobs avatar Jan 04 '23 23:01 chrispobs

@chrispobs Do you have a CodeSandbox to reproduce this? I tested your use-case it works fine for me.

Technologeek avatar Jan 20 '23 10:01 Technologeek

I'm also having the same issue. how could i sort it out

Rutra-Selvi-Thavamani avatar Mar 05 '23 09:03 Rutra-Selvi-Thavamani

I think this happens when the parent component re-renders when an option is selected (controlled select). And if you haven't memoized the options array then the menu list re-renders (and loses focus). Set closeMenuOnSelect={false} and isMulti={true} so the menu stays open after selection.

This doesn't work ❌ image

This works ✅ image

Even though this is fixable on the app side by memoized options, I think this should still be fixed on the component side. Or at least documented.

Edit: Added a codesandbox

HarlesPilter avatar Jan 23 '24 07:01 HarlesPilter