Skip to content
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

Adjust min-height for VirtualizedScroll #1143

Closed
wants to merge 7 commits into from

Conversation

LostABike
Copy link
Contributor

@LostABike LostABike commented Mar 16, 2023

Changes

ComboBox min-height calculation (line 420 VirtualScroll.tsx) is no longer accurate, because it assumes all middle child height are the same which is not always true as there can be child with sublabel and child without. I made a new function to calculate each individual heights and use that to set min-height instead.

But side note, because it is a "min-height", I feel like it might be better to calculate shortest node multiply by the amount of node instead? Since min-height is supposed to be the floor.

Closes #1107

Testing

Docs

@LostABike LostABike requested a review from a team as a code owner March 16, 2023 19:36
@LostABike LostABike requested a review from a team March 16, 2023 19:36
@LostABike LostABike self-assigned this Mar 16, 2023
Copy link
Contributor

@elephantcatdog elephantcatdog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like VirtualScroll is a utility that can be and is used for more than just ComboBox; did you take that into consideration?

Also, I'm a bit uncertain on what problem you're trying to solve with this. Can you send me the code you used to test it? Nevermind I see the linked issue now.

@gretanausedaite gretanausedaite linked an issue Mar 20, 2023 that may be closed by this pull request
@LostABike
Copy link
Contributor Author

LostABike commented Mar 20, 2023

It looks like VirtualScroll is a utility that can be and is used for more than just ComboBox; did you take that into consideration?

Also, I'm a bit uncertain on what problem you're trying to solve with this. Can you send me the code you used to test it? Nevermind I see the linked issue now.

@elephantcatdog You're right, it is probably better to calculate the height of each node individually instead, which I just updated. I also included sandbox in the description for the testing code that can be copied into vite. Also my bad I forgot to add the "closes x" or linking the problem 😅

@veekeys
Copy link
Member

veekeys commented Mar 20, 2023

It looks like VirtualScroll is a utility that can be and is used for more than just ComboBox; did you take that into consideration?
Also, I'm a bit uncertain on what problem you're trying to solve with this. Can you send me the code you used to test it? Nevermind I see the linked issue now.

@elephantcatdog You're right, it is probably better to calculate the height of each node individually instead, which I just updated. I also included sandbox in the description for the testing code that can be copied into vite. Also my bad I forgot to add the "closes x" or linking the problem 😅

VirtualScroll DOES NOT support dynamic height elements (I think it was documented somewhere). That basically means, if list consists of items of different height, miscalculations are expected. So to fix these, need to add support of dynamic heights elements, which is not that straight forward. I did have a branch with trying to add this feature. I will try to find time and see if I can revert that stash from somewhere.

@elephantcatdog
Copy link
Contributor

@LostABike You've got some visual storybook tests failing for combobox and table.

@LostABike LostABike marked this pull request as draft March 21, 2023 16:16
@veekeys
Copy link
Member

veekeys commented Mar 27, 2023

Ok, I pushed a VERY OLD code here
https://github.com/iTwin/iTwinUI/tree/vyki/dynamic-virtual-scroll
If you somehow make the build pass (mine failed on storybook, could not figure why), you should be able to see this working with table rows of different heights.
Again, would need to take the logic out and apply to current VS component, but hope this code will be useful for you guys to work on.
I might check it up myself, but currently have a lot of different stuff on my plate, so just physically cannot do it rn.
Please tag me on the PR, if you apply some of these and make it work, would be really interesting to see!

@LostABike LostABike closed this Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Virtualized ComboBox miscalculates height of options
3 participants