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

Possible bug in GridPro when re-ordering columns, recalculateColumnWidths fails #8253

Open
MikaelFiil opened this issue Dec 1, 2024 · 0 comments

Comments

@MikaelFiil
Copy link

MikaelFiil commented Dec 1, 2024

Description

I have a layout bug in GridPro that perhaps is related to either event chaining or timing.
It occurs after creating new columns, trying a recalculateColumnWidths() doesn’t help if done in the same event.

I only have the example from my repo, I don't have a small code example, sorry.
It is of cause possible that I have a bug, but the difference in the executed code from "bad layout" to "good layout" is very simple and to setup the example I need my repo demo.

I have a Select component that, during a valueChange event, triggers new columns creation and layout in the GridPro grid. After creating new columns I may or may not call recalculateColumnWidths() in the same valueChange event from the Select. In either casee the result is a GridPro with empty space between the rows, but when I either click a button or let a timer fire, then the call to recalculateColumnWidths() works fine. Here is a bit of code to give an idea:

startYear.addValueChangeListener(evt -> {
    itemSubView.resetGrid(makeParams());
    itemSubView.genericGrid.recalculateColumnWidths();      // Doesn't work

    timer.setStartTime(3);
    timer.start();
});

refreshBtn.addClickListener(evt -> {
    itemSubView.genericGrid.recalculateColumnWidths();      // Now it works
});

timer.addTimerEndEvent(ev-> {
    System.out.println("tick");
    itemSubView.genericGrid.recalculateColumnWidths();      // Now it works
});

The test is a lot of code so you have to go and download the code to recreate it, use the “GridPro Generator Test” menu and try changing the Select values:

https://github.com/MikaelFiil/vaadin-gridpro-generator?tab=readme-ov-file

Here is how it look when it fails:

a5af3a0d82396b87e2c37a95297bdbc668da8929

It doesn't seem to be related to issue #1864 since recalculateColumnWidths works the first time, it just has to be called after the initial event.

Expected outcome

I would expect the rows to be without extra space between them, like the image in the repo.

Minimal reproducible example

There is a lot of code behind the test, you have to download from here, sorry

https://github.com/MikaelFiil/vaadin-gridpro-generator?tab=readme-ov-file

Steps to reproduce

The test is a lot of code so you have to download the code to recreate it, then use the “GridPro Generator Test” menu and try changing the Select values.
Take a look in GridProGeneratorTest.java

Environment

OpenJDK 21.0.1
Vaadin 24.5.6
Spring boot 3.4.0
OS: Win 11

Browsers

Latest Firefox and Edge

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants