-
-
Notifications
You must be signed in to change notification settings - Fork 922
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
Can't use virtualized and renderMenuItem together in the SelectPicker #3187
Comments
Hi @hedzerkoolstra, when you want to render items with custom height in a virtualized list, you need to specify <SelectPicker
data={data}
renderMenuItem={menuItem}
virtualized
listProps={{
itemSize: (index) => 66 // 50px item height + 8px padding top and bottom
}}
/> Ref: |
Thanks for the reply. The height is fixed although my actual project has variable heights so I need a way to determine the height there but I can maybe find a way, But the width issues is not yet addressed. When using virtualized the menu list get the size of picker again instead of taking the full-width. |
That's because the <SelectPicker
data={data}
renderMenuItem={menuItem}
virtualized
listProps={{
itemSize: (index) => 66 // 50px item height + 8px padding top and bottom
}}
style={{ width: 224 }}
menuStyle={{
width: 424 // 400px item width + 12px padding left and right
}}
/> |
Thanks for the explanation. So this means virtualized can work, but if you specify the height and width statically. I have dynamic heights and width based on the options I render, is it the not possible to use it? |
As of width, if I understand correctly, you only need to set the menu's width to the maximum width among all items, rather than setting each menuitems' widths individually 🤔️. |
Yes I could do it with index but then I need to do some extra checks in that function indeed. It's all possible but the CSS worked straight out of the box without virtualized while now I need to do some calculations myself and then set menuItem height and menu width manually. It's more code and more bug prone so I was hoping there would be a way without needing to that. I'll consider the trade-off, thanks! |
That's how virtualization is designed and implemented for now. Every item is absolutely positioned and their position is calculated based on other items before them. Thus it has to know the size of each item before they are actually mounted in the document, otherwise you'll get a layout shift. |
Ok, thanks for the clarification! |
What version of rsuite are you using?
latest
What version of React are you using?
17.0.0
What version of TypeScript are you using (if any)?
No response
What browser are you using?
Chrome
Describe the Bug
Combining virtualized and renderMenuItem in the SelectPicker doesn't work together. When using just renderMenuItem the custom menuItem renders fine, when adding virtualized prop the height and width of the container get changed and this messes up the menuList component.
Expected Behavior
Be able to use virtualized and renderMenuItem together.
To Reproduce
https://codesandbox.io/s/serene-mahavira-8evty0?file=/index.js
The text was updated successfully, but these errors were encountered: