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

Adding a new item to Grid's DataProvider and using scrollToIndex to the end, shows empty rows in the top. #1889

Closed
johannest opened this issue Feb 20, 2020 · 3 comments · Fixed by #2067
Assignees
Labels
BFP Bug fix prioritised by a customer bug Something isn't working flow

Comments

@johannest
Copy link

Vaadin 14.1.17, Chome (Win 10).

Issue description: When having a Grid with empty space in the bottom (row count less than grid's size). And, adding a new item(s) to backing (list) dataprovider, and using scrollToIndex to scroll to the end. Then, for each item, an empty row is shown in the top of the Grid like in the screenshot below:
image

Code example to reproduce the issue:

@Route("scrollTo")
@Theme(Lumo.class)
public class GridScrollToTest extends VerticalLayout {

    private Grid<Dto> grid = null;
    private ListDataProvider<Dto> dataProvider;

    public GridScrollToTest() {
        setSizeFull();
        Button addItem = new Button("Add");
        addItem.addClickListener(buttonClickEvent -> {
            dataProvider.getItems().add(getNewMockDto());
            dataProvider.refreshAll();
            grid.scrollToIndex(dataProvider.getItems().size());
        });

        grid = new Grid<>(Dto.class);
        List<Dto> data = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            data.add(getNewMockDto());
        }
        dataProvider = new ListDataProvider<>(data);
        grid.setDataProvider(dataProvider);

        add(addItem, grid);
    }

    private Dto getNewMockDto() {
        return new Dto(UUID.randomUUID().toString());
    }

    public static class Dto {
        private String uuid;

        public Dto(String uuid) {
            super();
            this.uuid = uuid;
        }

        public String getUuid() {
            return uuid;
        }
    }
}

@johannest
Copy link
Author

@Frettman
Copy link

scrollToEnd seems to have the exact same issue. And it's not just additional empty space at the top: when this happends it seems to remove/replace my top most item. This seems to be triggered when adding an item makes scrolling necessary.

@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-grid-flow Oct 6, 2020
@vaadin-bot vaadin-bot added bug Something isn't working flow labels Oct 6, 2020
@tomivirkki tomivirkki added the BFP Bug fix prioritised by a customer label Oct 9, 2020
@yuriy-fix yuriy-fix self-assigned this Oct 19, 2020
@mvysny
Copy link
Member

mvysny commented Nov 11, 2020

@yuriy-fix Hello, will this be back-ported to Vaadin 14.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BFP Bug fix prioritised by a customer bug Something isn't working flow
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants