On Wed, 30 Mar 2022 13:27:40 GMT, Johan Vos <j...@openjdk.org> wrote:
>> When the size of a ListCell is changed and a scrollTo method is invoked >> without having a layout calculation in between, the old (wrong) size is used >> to calculcate the total estimate. This happens e.g. when the size is changed >> in the `updateItem` method. >> This PR will immediately resize the cell and sets the new value in the cache >> containing the cellsizes. > > Johan Vos has updated the pull request incrementally with one additional > commit since the last revision: > > Don't shift cells if we are already showing the lowest index cell. I noticed this bug as well, but in my case even when the `CellHeight` stays the same (so I'm not sure if it's the same or something else)... A minimal repro example: public class ApplicationUI extends VBox { private final ObservableList<String> elements = FXCollections.observableArrayList(); public ApplicationUI() { Button button = new Button("Add New Element"); ListView<String> listView = new ListView<>(elements); setVgrow(listView, Priority.ALWAYS); getChildren().addAll(listView, button); button.setOnAction(event -> { elements.add(String.valueOf(elements.size())); }); elements.addListener((ListChangeListener<String>) c -> { while (c.next()) { listView.scrollTo(c.getFrom()); } }); } } Click the button until there is a scroll bar, it always seems to scroll down to the second last element in the list, instead of the last. Interestingly, changing the line from `listView.scrollTo(c.getFrom());` to `listView.scrollTo(c.getFrom()-1);` or `listView.scrollTo(c.getFrom()+1);` results in the same behavior, however changing it to `listView.scrollTo(c.getFrom()-2);` does scroll correctly to the last item in the list? Just thought I would share this in case this would help find the issue. ------------- PR: https://git.openjdk.java.net/jfx/pull/712