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
Endless loop of horizontal and vertical scrollbar visibility change in Grid #12289
Comments
Hi @Ansku, could you send me a minimal example template project I could use to try to reproduce this issue? |
Have you tested the newest version of Vaadin 8, i.e. 8.13.0? I am asking this, since this patch was included in 8.12.1 https://github.com/vaadin/framework/pull/12145/files And it fixes reported regression #12139 which is similar to yours |
Hi, yes as you can see in the patch I tested with 8.13.0 and patched revision 5b06221 to verify this. I saw this fix, but didn't understand the idea of the new
Maybe that has to be done another way to avoid an endless loop? |
I'm not quite sure what you are looking for exactly, but https://vaadin.com/vaadin-8/get-started has instructions for creating basic projects with different tools, https://github.com/vaadin/vaadin8-example has an existing example project without a Grid, and https://github.com/vaadin/framework/tree/master/uitest/src/main/java/com/vaadin/tests/components/grid contains a random collection of regression tests UI with different sorts of Grids -- they aren't really meant as code examples and they are only updated when something breaks, so don't expect them to be pretty or to follow best practices, but I'd assume there's something to get you started. I guess my first question would be: why do you want to call |
To clarify: did you test 8.13.0 without the changes in your patch too? |
Hi @Ansku, yes of course. I tested 8.12.3, 8.12.4 and 8.13.0 without changes, too. |
Because we had certain situations were the automatics didn't work properly. I already deactivated all of this calls and it stays in the endless loop also for only having the restore of the weight changes from user settings. I still try to analyze how to avoid the endless loop from our side, but for this issue here I would argue more generally that an endless loop protection for all theoretical calls of recalculate column widths in connection with the described loop (horizontal bar -> vertical bar -> ...) would really be a good safe guard. |
That is sadly easier said than done without getting it needlessly stuck in other situations. But if you can provide me a reproducible example I'll certainly give it another shot :) |
One option that could trigger unwanted resizing is if your theme contains something that affects the column widths. It's generally safer to do settings like that through the code, since the column width calculation logic is quite complicated. |
I tried to find the API to do that via code, can you indicate me to the correct methods to do so? While I still fear the efforts for the minimal example will be beyond my possibilities, I saw the reason for the appearance of the horizontal scrollbar. It's coming from the complicated (I tend to say ugly) calculation logic itself:
Where in 8.13.0 in line 3630 columns where expanded, although pixelsToDistribute are in my endless loop really negative (-6), this is leading to a scrollbar that is needed. I could successfully patch only this place. After this change the grid is rendered successfully and no loop is freezing the GUI anymore. As the comment below this code also says that further calculations break the GridEditRow test I would suggest to apply my patch to avoid my endless loop case. At least for really negative pixels this should be changed!
Also the idea for minimal example gets clearer, the grid needs to have space to expand the columns, but the weights must round up to a too large expansion to be in this special case noted above. |
I could fix the loop by removing the width settings from CSS and using Column.setWidth() only. For details see https://stackoverflow.com/questions/67474238/vaadin-8-grid-scrollbars-behave-erratically-when-css-is-used-for-column-widths/ |
Vaadin Framework version: 8.12.0.alpha1
Browser version: Windows Chrome Version 90.0.4430.93 (64 bit)
Web container name and version: Payara 5.2020.2
Description of the bug
Minimal reproducible example
com.vaadin.ui.Grid#recalculateColumnWidths
from different cases to get the minimal example working, we have that e.g. forgrid.addColumnReorderListener((ColumnReorderListener) event -> grid.recalculateColumnWidths());
Expected behavior
Actual behavior
I verified that removing the new part from verticalScrollbar.addVisibilityHandler in line 7347 of Escalator from #12058 prevents this endless loop. As I understood this might be needed in other cases it would be good to have a endless loop detection to prevent this very generally.
Here is my patch I used for verfication:
The text was updated successfully, but these errors were encountered: