JedWatson / react-select

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

closeMenuOnScroll not working #5675

Open santialbo opened 1 year ago

santialbo commented 1 year ago

closeMenuOnScroll seems to not be working Reproduction: https://codesandbox.io/s/codesandboxer-example-forked-wppm3h?file=/example.tsx

Debugging the code I see the following check is being done https://github.com/JedWatson/react-select/blob/a465818786afd4857c9155bef1e9aa2fe3356097/packages/react-select/src/Select.tsx#L1281

which is not passed when scrolling as document is not an HTMLElement.

levipadre commented 1 year ago

Same problem here

elsheraey commented 1 year ago

It's a callback, please try closeMenuOnScroll={() => true}

therealtgd commented 1 year ago

Then it closes the menu even if the user scrolls inside of it.

ashahin101 commented 5 months ago

@therealtgd > Then it closes the menu even if the user scrolls inside of it.

Even if you just pass "closeMenuOnScroll" as a prop (which is technically equal to true) as react-select docs suggests; still it doesn't work.

ashahin101 commented 5 months ago

this work fine for me

const handleCloseMenuOnScroll = e => !e.target.className?.includes("MenuList")? true : false
return (
    <Select
        closeMenuOnScroll={handleCloseMenuOnScroll}
        {...props}
    />
 )