Skip to content

fix: hide already-filtered values from other spreadsheet column filters (#9386) (CP: 25.1)#9464

Merged
vursen merged 1 commit into
25.1from
cherry-pick-9386-to-25.1-1781072621605
Jun 10, 2026
Merged

fix: hide already-filtered values from other spreadsheet column filters (#9386) (CP: 25.1)#9464
vursen merged 1 commit into
25.1from
cherry-pick-9386-to-25.1-1781072621605

Conversation

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This PR cherry-picks changes from the original PR #9386 to branch 25.1.

Original PR description

Description

In a SpreadsheetFilterTable with filters on multiple columns, opening any column's filter dropdown showed values from rows already hidden by other columns as unchecked, suggesting they were filtered by this column. Re-checking them did nothing because another column still hid the row.

Applying a second filter then implicitly added those already-hidden rows to the second column's filteredRows, so clearing the first filter did not bring the rows back — the second column now also filtered them.

Root cause: ItemFilter read spreadsheet.isRowHidden(r) for both building option lists and deciding which rows belong in its own filteredRows. That property reflects the union of all column filters, so each filter could not tell its own work from a sibling's.

Each ItemFilter now operates only on its own filteredRows. The dropdown option list omits values whose rows are all hidden by other columns via a new SpreadsheetFilterTable.getRowsHiddenByOtherFilters(self) helper. clearAllFilters does a second pass to refresh option lists so cleared siblings are reflected immediately.

Fixes #9329

Reproduction

@Route("spreadsheet-filter-cross-column")
public class SpreadsheetFilterCrossColumnPage extends VerticalLayout {

    public SpreadsheetFilterCrossColumnPage() {
        Spreadsheet spreadsheet = new Spreadsheet();
        spreadsheet.setTheme(SpreadsheetTheme.LUMO);
        spreadsheet.setHeight("400px");

        spreadsheet.createCell(0, 0, "Column A");
        spreadsheet.createCell(0, 1, "Column B");
        spreadsheet.createCell(0, 2, "Column C");

        spreadsheet.createCell(1, 0, "Alpha");
        spreadsheet.createCell(1, 1, "Foo");
        spreadsheet.createCell(1, 2, "Alice");

        spreadsheet.createCell(2, 0, "Beta");
        spreadsheet.createCell(2, 1, "Bar");
        spreadsheet.createCell(2, 2, "Bob");

        spreadsheet.createCell(3, 0, "Gamma");
        spreadsheet.createCell(3, 1, "Baz");
        spreadsheet.createCell(3, 2, "Carol");

        CellRangeAddress range = new CellRangeAddress(0, 3, 0, 2);
        SpreadsheetFilterTable table = new SpreadsheetFilterTable(spreadsheet,
                range);
        spreadsheet.registerTable(table);
        spreadsheet.refreshAllCellValues();

        add(spreadsheet);
    }
}
Column A Column B Column C
Alpha Foo Alice
Beta Bar Bob
Gamma Baz Carol

Steps to reproduce:

  • Filter Beta in column A.
  • Open the filter dropdown in column B → Bar shows up unchecked (before the fix), suggesting column B filtered it.
  • Filter Foo in column B.
  • Re-check Beta in column A → the row does not reappear (before the fix), because column B now also filters it.

🤖 Generated with Claude Code

…rs (#9386)

## Description

In a `SpreadsheetFilterTable` with filters on multiple columns, opening
any column's filter dropdown showed values from rows already hidden by
other columns as unchecked, suggesting they were filtered by this
column. Re-checking them did nothing because another column still hid
the row.

Applying a second filter then implicitly added those already-hidden rows
to the second column's `filteredRows`, so clearing the first filter did
not bring the rows back — the second column now also filtered them.

Root cause: `ItemFilter` read `spreadsheet.isRowHidden(r)` for both
building option lists and deciding which rows belong in its own
`filteredRows`. That property reflects the union of all column filters,
so each filter could not tell its own work from a sibling's.

Each `ItemFilter` now operates only on its own `filteredRows`. The
dropdown option list omits values whose rows are all hidden by other
columns via a new
`SpreadsheetFilterTable.getRowsHiddenByOtherFilters(self)` helper.
`clearAllFilters` does a second pass to refresh option lists so cleared
siblings are reflected immediately.

Fixes #9329

## Reproduction

```java
@route("spreadsheet-filter-cross-column")
public class SpreadsheetFilterCrossColumnPage extends VerticalLayout {

    public SpreadsheetFilterCrossColumnPage() {
        Spreadsheet spreadsheet = new Spreadsheet();
        spreadsheet.setTheme(SpreadsheetTheme.LUMO);
        spreadsheet.setHeight("400px");

        spreadsheet.createCell(0, 0, "Column A");
        spreadsheet.createCell(0, 1, "Column B");
        spreadsheet.createCell(0, 2, "Column C");

        spreadsheet.createCell(1, 0, "Alpha");
        spreadsheet.createCell(1, 1, "Foo");
        spreadsheet.createCell(1, 2, "Alice");

        spreadsheet.createCell(2, 0, "Beta");
        spreadsheet.createCell(2, 1, "Bar");
        spreadsheet.createCell(2, 2, "Bob");

        spreadsheet.createCell(3, 0, "Gamma");
        spreadsheet.createCell(3, 1, "Baz");
        spreadsheet.createCell(3, 2, "Carol");

        CellRangeAddress range = new CellRangeAddress(0, 3, 0, 2);
        SpreadsheetFilterTable table = new SpreadsheetFilterTable(spreadsheet,
                range);
        spreadsheet.registerTable(table);
        spreadsheet.refreshAllCellValues();

        add(spreadsheet);
    }
}
```

| Column A | Column B | Column C |
| -------- | -------- | -------- |
| Alpha    | Foo      | Alice    |
| Beta     | Bar      | Bob      |
| Gamma    | Baz      | Carol    |

Steps to reproduce:

- Filter `Beta` in column A.
- Open the filter dropdown in column B → `Bar` shows up unchecked
(before the fix), suggesting column B filtered it.
- Filter `Foo` in column B.
- Re-check `Beta` in column A → the row does not reappear (before the
fix), because column B now also filters it.

🤖 Generated with Claude Code

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vursen
vursen enabled auto-merge (squash) June 10, 2026 06:31
@vursen
vursen disabled auto-merge June 10, 2026 06:31
@vursen
vursen enabled auto-merge (squash) June 10, 2026 06:31
@sonarqubecloud

Copy link
Copy Markdown

@vursen
vursen merged commit 9d68d31 into 25.1 Jun 10, 2026
9 checks passed
@vursen
vursen deleted the cherry-pick-9386-to-25.1-1781072621605 branch June 10, 2026 06:58
@vaadin-bot

Copy link
Copy Markdown
Collaborator Author

This ticket/PR has been released with Vaadin 25.1.8.

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.

2 participants