Skip to content

Grid frozen-at-end-column position isn't refreshed correctly when Grid items change #6666

@OlliTietavainenVaadin

Description

@OlliTietavainenVaadin

Description

When you have a Grid with one or more frozen columns at the end, and the Grid displays both a vertical and a horizontal scrollbar, applying e.g. a filter to reduce the number of items can cause the vertical scrollbar to disappear. This is currently not causing a recalculation of the frozen column position, but you can trigger the calculation e.g. by moving the horizontal scrollbar a little or resizing the browser window:
filter

Expected outcome

Changing the item list should also recalculate the frozen-to-end column position if needed

Minimal reproducible example

public class HelloWorldView extends HorizontalLayout {


    public HelloWorldView() {
        setSizeFull();
        VerticalLayout layout = new VerticalLayout();
        Grid<String> grid = new Grid<>();
        List<String> letters = new ArrayList<>();
        for (char c = 'a'; c < 'z'; c++) {
            letters.add(c + "");
        }
        GridListDataView<String> stringGridListDataView = grid.setItems(letters);
        Button filterButton = new Button("Filter list");
        filterButton.addClickListener( e-> stringGridListDataView.addFilter( s -> s.equals("a")) );
        layout.add(filterButton);
        grid.addColumn(s -> "Foo").setHeader("Id");
        grid.addColumn(s -> "Bar").setHeader("First name");
        grid.addColumn(s -> "Baz").setHeader("Last name");
        grid.addColumn(s -> "Bizzle").setHeader("Birth date");
        grid.addColumn(s -> "Quux").setHeader("Phone");
        grid.addColumn(s -> "Zyzzyx").setHeader("Address");
        grid.addColumn(p ->"Eius ducimus numquam provident est. Est dolorum odit soluta quia accusamus error fugiat. Alias beatae ut maiores eos.").setHeader("Lorem");
        grid.addComponentColumn(p -> {
            Button button = new Button(LumoIcon.PHONE.create());
            button.addThemeVariants(ButtonVariant.LUMO_ICON);
            return button;
        }).setHeader("Call").setFrozenToEnd(true);
        layout.add(grid);
        add( layout);
    }

}

Steps to reproduce

  1. Resize your browser so that the Grid gains a horizontal scrollbar
  2. Click the "filter list" button
  3. Observe that the frozen column at the end is off by the width of the vertical scrollbar that is no longer there
  4. Move the horizontal scrollbar a bit
  5. Observe that the frozen column pops in the right place

Environment

Vaadin version(s): 24.4.4
OS: Windows 11

Browsers

Issue is not browser related

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions