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

Scrolling quickly to the bottom of the dropdown shows blank items #970

Closed
johannesh2 opened this issue Nov 16, 2020 · 1 comment · Fixed by #978
Closed

Scrolling quickly to the bottom of the dropdown shows blank items #970

johannesh2 opened this issue Nov 16, 2020 · 1 comment · Fixed by #978

Comments

@johannesh2
Copy link

johannesh2 commented Nov 16, 2020

Description

Scrolling a lazy loading combo box to the bottom of the result sets shows blank dropdown. Scrolling back up a bit, reveals the items.

Code

import java.util.ArrayList;
import java.util.Optional;
import java.util.stream.Stream;

import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.data.provider.Query;
import com.vaadin.flow.router.Route;

@Route("lazycombo")
public class LazyCombo extends VerticalLayout {
  static final ArrayList<String> list = new ArrayList<>();
  static final int MAX_ITEMS = 500;
  static {
    for (int i = 1; i <= MAX_ITEMS; i++) {
      list.add(String.valueOf(i));
    }
  }
  
  public LazyCombo() {
    ComboBox<String> combo = new ComboBox<>();
    combo.setItems(this::items);
    add(combo);
  }
  
  private int count(Query<String, String> q) {
    int count = (int) filteredItems(q).count();
    return count;
  
  }
  
  private Stream<String> items(Query<String, String> q) {
    return filteredItems(q).skip(q.getOffset()).limit(q.getLimit());
  }
  
  private Stream<String> filteredItems(Query<String, String> q) {
    return list.stream().filter(item -> doFilter(item, q.getFilter()));
  }
  
  private boolean doFilter(String item, Optional<String> filter) {      
    if (filter.isEmpty()) {
      return true;
    } else {
      return item.contains(filter.get()); 
    }
  }
}

Gif

comboscrollbug

Tested with V18 beta2. On Win 10 Chrome 86

@mshabarov
Copy link
Collaborator

This happens when you drag and scroll sharply. Apparently, 2-3 last pages are not requested from backend and, thus, rendered.

This video shows two cases: with sharp scrolling and with smooth scrolling. All the pages are fetched in second case.

https://drive.google.com/file/d/1EtyuPIXFifKKuawuCslORf9aspp5pFBP/view?usp=sharing.

Proceed with investigation.

@mshabarov mshabarov self-assigned this Nov 26, 2020
mshabarov added a commit that referenced this issue Dec 2, 2020
When the dropdown was being scrolled quickly, some pages weren't being loaded and skipped in the end. It's fixed by resending the skipped pages after the scroller reset and filter those indexes which are close to current scroller position, so as to avoid unnecessary duplicated pages and loading indicator hanging.

Fixes: #970
OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from In progress to Done - pending release Dec 4, 2020
mshabarov added a commit that referenced this issue Dec 4, 2020
When the dropdown was being scrolled quickly, some pages weren't being loaded and skipped in the end. It has been fixed by resending the skipped pages after the scroller reset and filter those indexes which are close to current scroller position, so as to avoid unnecessary duplicated pages and loading indicator hanging.

Fixes: #970
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
OLD Vaadin Flow ongoing work (Vaadin ...
  
Done - pending release
Development

Successfully merging a pull request may close this issue.

3 participants