Problem with default sort order in grid

Hello!

We are using Vaadin 14.1.5.

We have got a grid and want to sort the second column by default:

We wrote following code:

                final com.vaadin.flow.component.grid.Grid.Column                                                                          column0 = grid
                        .getColumns().get(1);
                final java.util.ArrayList<com.vaadin.flow.component.grid.GridSortOrder<de.tricept.vaadin.services.mcockpit.TableDataRow>> sort    = new java.util.ArrayList<com.vaadin.flow.component.grid.GridSortOrder<de.tricept.vaadin.services.mcockpit.TableDataRow>>();
                final com.vaadin.flow.component.grid.GridSortOrder<de.tricept.vaadin.services.mcockpit.TableDataRow>                      order   = new com.vaadin.flow.component.grid.GridSortOrder<de.tricept.vaadin.services.mcockpit.TableDataRow>(
                        column0, com.vaadin.flow.data.provider.SortDirection.ASCENDING);
                sort.add(order);
                grid.sort(sort);

All is fine. The grid sorts header of second colum is marked blue and the right sort arrow is highlighted.

But there is a problem: Whe we click on anonther column header to sort this one we have got to click twice.

After the second click sorting goes on.

Why we have got to click two times?

Thank you very much,
Thomas

Tested (and used) your code to sort our grid and it works fine with the latest Vaadin 14.1.25. First click on another column header sorts that column ASC, second click sorts DESC. Haven’t tested with any previous version.

ArrayList<GridSortOrder<XXXDetails>> sort = new java.util.ArrayList<>();
GridSortOrder<XXXDetails> order = new GridSortOrder<>(xxxDetailsGrid.getColumns().get(0), com.vaadin.flow.data.provider.SortDirection.ASCENDING);
sort.add(order);
xxxDetailsGrid.sort(sort);