vaadin / vaadin/framework

Changing amount of item in Table loses horizontal scrolling position

Open
#4,496 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Stale v7
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Originally by Tapio Aali


If a Table has been scrolled horizontally and the amount of items displayed in it changes, the scroll position is lost.

Example:

VerticalLayout layout = new VerticalLayout();
setContent(layout);

final Table table = new Table();
table.setWidth("640px");
table.setHeight("243px");
layout.addComponent(table);

for (int i = 0; i < 50; i++) {
    table.addContainerProperty("Column " + i, String.class, null);
}

for (int i = 0; i < 200; i++) {
    table.addItem();
}

Button reduceItems = new Button("Reduce items",
        new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                table.removeAllItems();
                for (int i = 0; i < 5; i++) {
                    table.addItem();
                }
            }
        });
layout.addComponent(reduceItems);

Just scroll right and then click "reduce items". The horizontal scrolling position resets.


Imported from https://dev.vaadin.com/ issue #12652

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names the Table entry point but no source file or test. Reproduce the example by scrolling right and changing the item count, then trace the Table behavior responsible for preserving horizontal position; done means the position remains unchanged after items are removed and the regression is covered by a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.