I'm having some trouble understanding how I'm supposed to detect a scroll event with a Select component using Material-UI.
I have a Select that has MenuProps={...}. I want to be able to listen to the scroll event inside this Select, so what I'm doing is putting onScroll inside the MenuProps={...}. But the event is never fired.
What I've already tried:
overflow: 'auto' next to the style object in MenuProps={...}. It results in the list blinking for a second (on top of the Select instead of the bottom) and disappearing.Could someone help me please?
After digging in the Material-UI source code, I've found that you need to attach the scroll listener to the Paper component, so this is the working code:
MenuProps={{
PaperProps: {
onScroll: (event: any) => {
console.log(event);
console.log("we scroll");
}
},
}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With