-
Notifications
You must be signed in to change notification settings - Fork 794
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
Select component is not scrollable in shadow dom #1980
Comments
I think I'm having the same issue. This is Select in the "popper" position. I have the same set of items twice: once where the origin gives enough space for the full menu, and one in the middle of the screen where it doesn't: CleanShot.2023-03-22.at.10.38.05.mp4Is there a workaround (other than using "item-aligned")? |
I'm also experiencing this when using |
Hey @focux — I think we ended up setting a max height. It's not ideal because in theory you have to set it to be less than half the screen (for when the trigger is in the middle), and that looks bad when the trigger is up top. But sure that's life. |
Have you tried using https://www.radix-ui.com/docs/primitives/components/select#constrain-the-content-size |
Just tried and it didn't work. |
It should work 🤔. Is your select in a shadow dom too? |
Is there a reason why there is no scrollbar visible with |
I was able to fix the issue by adding a data-scrollable to part of the dropdown content which should be scrollable and then adding this event listeners.
|
Could you be kind to share your code on where you pasted the data-scrollable and where you inserted the useEffect? |
Hello! So the useEffect I put in App.tsx (I'm using React.js), basically it should run on app mount. And as for the data-scrollable, I just passed it as prop to element inside DropdownContent which should be scrollable.
|
Thank you, it works flawlessly! |
For reference adding this class worked for me.
|
Hi, thank you for the workarounds. |
The fix was released in Until this gets merged, you can either update the lockfile manually to enforce the dependency's version (not recommended) or wrap the scrollable element in this component: function ScrollableContainer({ children, ...props }: React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
const element = ref.current!;
const handleWheel = (e: WheelEvent) => {
e.stopPropagation();
};
const handleTouchMove = (e: TouchEvent) => {
e.stopPropagation();
};
element.addEventListener('wheel', handleWheel, true);
element.addEventListener('touchmove', handleTouchMove, true);
return () => {
element.removeEventListener('wheel', handleWheel, true);
element.removeEventListener('touchmove', handleTouchMove, true);
};
}, []);
return (
<div {...props} ref={ref}>
{children}
</div>
);
} |
Fixed by #2765 |
Bug report
Select component is not scrollable in shadow dom due to a bug of react-remove-scroll
Here is a link of that bug - theKashey/react-remove-scroll#45
Reproducible example
CodeSandbox Template
The text was updated successfully, but these errors were encountered: