Skip to content

fix: hide already-filtered values from other spreadsheet column filters#9386

Merged
vursen merged 7 commits into
mainfrom
fix/spreadsheet-cross-column-filter-9329
Jun 10, 2026
Merged

fix: hide already-filtered values from other spreadsheet column filters#9386
vursen merged 7 commits into
mainfrom
fix/spreadsheet-cross-column-filter-9329

Conversation

@vursen

@vursen vursen commented May 28, 2026

Copy link
Copy Markdown
Contributor

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

@vursen vursen changed the title fix: decouple spreadsheet column filters fix: hide already-filtered values from other spreadsheet column filters Jun 1, 2026
@vaadin vaadin deleted a comment from github-actions Bot Jun 2, 2026
@vursen
vursen marked this pull request as ready for review June 2, 2026 16:02
@vursen
vursen requested a review from DiegoCardoso June 8, 2026 05:29

@DiegoCardoso DiegoCardoso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an inconsistent behavior with this implementation. The unchecked values only appear at the last filtered column:

spreadsheet-filter.mp4

In the example above, I have set up the following table:

Column A Column B Column C Column D Column E
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
A4 B4 C4 D4 E4
A5 B5 C5 D5 E5
A6 B6 C6 D6 E6
A7 B7 C7 D7 E7
A8 B8 C8 D8 E8
A9 B9 C9 D9 E9

Here's what is done in the video:

  • I started by filtering out the "A2" and "A3" values from "Column A"
  • Upon closing and opening the filter popup in "Column A", the filtered out values appear unchecked
  • Then, I filtered out the "B4" value in "Column B"
  • Now, when I close and open the filter popup in "Column B", the "B4" values appears unchecked
  • BUT, when the filter popup in "Column A" is opened, no unchecked values appear

The only way to show the rows again is by clicking on the "Clear filters" button.

Perhaps, the values that have been filtered out by each column should remain available for checking back again?

@vursen
vursen force-pushed the fix/spreadsheet-cross-column-filter-9329 branch from 567ab82 to 15881d8 Compare June 9, 2026 06:50
@vursen

vursen commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Perhaps, the values that have been filtered out by each column should remain available for checking back again?

Yes, good catch, thanks. Fixed.

vursen and others added 7 commits June 9, 2026 15:58
Each ItemFilter previously read spreadsheet.isRowHidden, which reflects
the union of all column filters. Two consequences:

- Filter dropdowns showed values from rows hidden by other columns as
  unchecked, suggesting this column was filtering them.
- Applying a filter then absorbed those rows into this column's
  filteredRows, so clearing the other column did not bring them back.

Each filter now operates only on its own filteredRows. Dropdown option
lists omit values whose rows are all hidden by other columns (cosmetic).
clearAllFilters refreshes option lists in a second pass so cleared
siblings are reflected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
getVisibleValues now builds on getAllValues, so a column's option
list no longer shows values whose rows are already hidden by other
columns' filters.

Refs #9329
Reuses the cross-column repro page (renamed to a general
SpreadsheetFilterPage) and adds an IT that filters one column, then
asserts another column's filter dropdown omits values whose rows are
hidden by the first column.

Refs #9329

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drive popups via SpreadsheetElement and read values via
CheckboxGroupElement, and extend AbstractComponentIT directly since
AbstractSpreadsheetIT's getSpreadsheet() only works with the shared
demo page.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ItemFilter.updateFilteredItems looped over every row in the range and
claimed any whose value was not visible, including rows already hidden
by other columns. A second column thus absorbed the first column's
hidden rows, making the first column's filtered values disappear from
its option list. Skip rows hidden by other filters so each column owns
only the rows it filters itself.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Move the two cross-column filter tests onto the shared
  SpreadsheetTableFixture instead of a dedicated page
- Drop the now-redundant SpreadsheetFilterPage and SpreadsheetFilterIT
- Label fixture cells "Cell row:col" so filter values stay distinct
  and reveal which row and column each value belongs to
@vursen
vursen force-pushed the fix/spreadsheet-cross-column-filter-9329 branch from 15881d8 to 64f3a8e Compare June 9, 2026 15:33
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

@vursen
vursen added this pull request to the merge queue Jun 10, 2026
Merged via the queue into main with commit 179ac05 Jun 10, 2026
20 of 23 checks passed
@vursen
vursen deleted the fix/spreadsheet-cross-column-filter-9329 branch June 10, 2026 06:18
vursen added a commit that referenced this pull request Jun 10, 2026
…rs (#9386) (#9464)

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
> 
> ```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: Sergey Vinogradov <mr.vursen@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
sissbruecker pushed a commit that referenced this pull request Jun 22, 2026
…rs (#9386) (CP: 25.2) (#9578)

This PR cherry-picks changes from the original PR #9386 to branch 25.2.
---
#### 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
> 
> ```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: Sergey Vinogradov <mr.vursen@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

Spreadsheet: Inclusion of hidden values in filter dropdown is confusing

4 participants