Skip to content

fix: span row group to the last row of the sheet - #10183

Merged
DiegoCardoso merged 6 commits into
mainfrom
fix/row-group-ending-on-last-row
Sep 24, 2026
Merged

DiegoCardoso merged 6 commits into
mainfrom
fix/row-group-ending-on-last-row

Conversation

@totally-not-ai

@totally-not-ai totally-not-ai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10164

Summary

A row group that ends on the last row of a spreadsheet could not be collapsed. Its grouping marker also showed with no length. This change fixes how the end of the group is found, so these groups now work like all other row groups.

What changed

  • The code searches for the first row after the group that is not part of it. When a group ended on the last row, the search ran past the end of the sheet and returned -1 as the end index. The client then drew a marker with no length and used -1 to collapse and expand the group, so nothing happened.
  • Now, if the search finds no row outside the group, the end index is the last row of the sheet.
  • Removed the unused row parameter from the internal method GroupingUtil.findEndOfRowGroup.
  • Added a test sheet, row_group_at_last_row.xlsx, for the browser test.

Behavior change: This only affects row groups that end on the last row of the sheet. They now show a full-length marker and can be collapsed and expanded. Other groups work as before. There is no public API change, because GroupingUtil is package-private.

Test summary

Row grouping data:

  • End index is the last row when the group ends on the last row

Row level headers:

  • Clicking the level headers hides and then shows the last row again

Grouping marker (browser):

  • Marker covers all grouped rows
  • Collapse icon at the end of the group, not at its start
  • Clicking the marker collapses the group; clicking it again expands it

totally-not-ai Bot and others added 5 commits September 21, 2026 18:53
The end index of a row group was resolved as -1 when the group extended
to the last row of the sheet, because the search for the first row that
is not part of the group always ran past the end of the sheet. The
client then drew the grouping marker with no length and got -1 as the
index to use for collapsing and expanding the group, so the group could
not be collapsed at all.

Resolve the end index to the last row of the sheet when no row outside
the group is found.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds a test sheet where the row group ends on the last row of the sheet
and verifies that the grouping marker spans the grouped rows and that
clicking it collapses them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Drops the collapse and expand unit tests for a group ending on the last
row: the collapse and expand logic itself is already covered for other
sheets, and what is specific to this case - the group data sent to the
client and the row level headers - is covered by the remaining tests.
Merges the two browser tests into one, so that the sheet is loaded and
scrolled only once.

Also drops the unused row parameter of findEndOfRowGroup.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@DiegoCardoso
DiegoCardoso marked this pull request as ready for review September 23, 2026 13:59

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ Nothing to flag — the changes look good.

@DiegoCardoso

Copy link
Copy Markdown
Contributor

The fix looks good. The browser test covers most of #10164, but two things the issue asks for are not checked yet:

  • "The collapse icon is positioned at the group endpoint". The test checks the height of the bracket, but not where the icon is. Before the fix, the icon was at the top of the group, so this is worth checking directly.
  • "clicking again expands it". The test clicks once to collapse, but never clicks again to expand.

Both fit into grouping_rowGroupEndsOnLastRow_groupSpansRowsAndCollapses. For example:

        // the collapse icon is at the end of the group, not at its start
        WebElement collapseIcon = rowGrouping
                .findElement(By.cssSelector(".expand"));
        Assert.assertTrue("Collapse icon position",
                collapseIcon.getLocation().getY() >= spreadsheetElement
                        .getRowHeader(LAST_ROW).getLocation().getY());

        rowGrouping.click();
        waitUntil(driver -> !spreadsheetElement.getRowHeader(LAST_ROW)
                .isDisplayed());

        findElementInShadowRoot(
                By.cssSelector(".row-group-pane .grouping.plus")).click();
        waitUntil(driver -> spreadsheetElement.getRowHeader(LAST_ROW)
                .isDisplayed());

If you add the expand step, the test name could become ..._groupSpansRowsCollapsesAndExpands.

Checks that the collapse icon sits at the end of the group instead of at
its start, and that clicking the marker a second time expands the group
again.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@totally-not-ai

Copy link
Copy Markdown
Contributor Author

@DiegoCardoso Both checks are in now (8775249), and the test is renamed to grouping_rowGroupEndsOnLastRow_groupSpansRowsCollapsesAndExpands:

  • The icon position is asserted against the last row's header. It does catch the bug on its own: with the fix reverted, that assertion fails because the icon sits at the group start.
  • A second click expands the group again and the test waits for the last row to be displayed.

One deviation from your snippet: both clicks target the .expand icon instead of the marker div, because a collapsed marker has zero height, which makes clicking it unreliable. The click bubbles to the same handler.

GroupingIT passes 6/6 in headless Chrome.

@sonarqubecloud

Copy link
Copy Markdown

@DiegoCardoso
DiegoCardoso added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit 863ac23 Sep 24, 2026
18 checks passed
@DiegoCardoso
DiegoCardoso deleted the fix/row-group-ending-on-last-row branch September 24, 2026 07:07
@vaadin-bot

Copy link
Copy Markdown
Collaborator

Hi @totally-not-ai[bot] and @DiegoCardoso, when i performed cherry-pick to this commit to 24.10, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 863ac23
error: could not apply 863ac23... fix: span row group to the last row of the sheet (#10183)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

DiegoCardoso pushed a commit that referenced this pull request Sep 24, 2026
…10209)

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Fixes #10164
DiegoCardoso pushed a commit that referenced this pull request Sep 24, 2026
…10210)

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Fixes #10164
DiegoCardoso added a commit that referenced this pull request Sep 24, 2026
…#10212)

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Fixes #10164
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.4.0-alpha1.

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: a row group ending on the last row is rendered incorrectly and cannot be collapsed

3 participants