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

refactor: drop obsolete scroller workaround #7257

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

vursen
Copy link
Contributor

@vursen vursen commented Mar 22, 2024

Description

The _shouldSkipIndex workaround was introduced in vaadin/vaadin-combo-box#978 at a time combo-box had its own scroll restoration logic. However, this logic was later removed when replacing iron-list with virtualizer in #2339, which makes the workaround also obsolete. Note, there is no such workaround in grid.

Type of change

  • Refactor

@vursen vursen marked this pull request as draft March 22, 2024 09:35
@vursen vursen requested review from tomivirkki and removed request for tomivirkki and web-padawan March 22, 2024 09:36
@vursen
Copy link
Contributor Author

vursen commented Mar 22, 2024

Just to be on the safe side, I took the reproduction example from the original issue that the workaround aimed to fix and tested it on both Mac and Windows (Chrome). The issue was not reproducible with the workaround removed.

@Route("vaadin-combo-box/bug")
public class BugPage extends Div {
    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 BugPage() {
        ComboBox<String> comboBox = new ComboBox<>();
        comboBox.setItems(this::items);
        add(comboBox);
    }

    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());
        }
    }
}

@vursen vursen requested a review from web-padawan March 22, 2024 09:46
@vursen vursen marked this pull request as ready for review March 22, 2024 09:46
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@vursen vursen merged commit 5b41105 into main Mar 22, 2024
9 checks passed
@vursen vursen deleted the refactor/combo-box/remove-old-workaround branch March 22, 2024 12:15
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.4.0.alpha20 and is also targeting the upcoming stable 24.4.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants