Skip to content

refactor: render grid header and footer row parts declaratively#12225

Merged
vursen merged 8 commits into
mainfrom
declarative-grid-header-footer-row-parts
Jul 24, 2026
Merged

refactor: render grid header and footer row parts declaratively#12225
vursen merged 8 commits into
mainfrom
declarative-grid-header-footer-row-parts

Conversation

@vursen

@vursen vursen commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This PR continues the migration of the imperatively applied header/footer row and cell state into Lit templates. It covers:

  • first-header-row, last-header-row, first-footer-row, last-footer-row row parts with their -cell variants and matching classes
  • first-column / last-column attributes and first-column-cell / last-column-cell parts with matching classes on header and footer cells

Part of #10789

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the changes — left 2 comments and collected 1 finding below that could not be attached to the diff.

Finding
👀 Footer slot-name level numbering flipped, but only grid's snapshot was regenerated — the crud snapshot still has the old numbers.
The column tree is sorted twice per header/footer render instead of once.
🧹 #headerRows and #footerRows are near-identical getters differing only by the visibility function and .toReversed().

👀 Footer slot-name level numbering flipped, but only grid's snapshot was regenerated — the crud snapshot still has the old numbers.
The crud DOM snapshot embeds a grid with a 2-level column tree, so its footer content nodes carry slot names at both levels: vaadin-grid-footer-cell-content-1-1, 1-3, 1-4, 0-0, 0-2, 0-4. Because #footerRows now calls .toReversed() before the level-assigning .map(), the level passed to #renderFooterRow is the reversed index, so these footer slot names swap 0↔1 — exactly the swap the PR already applied to grid's own snapshot (grid.test.snap.js lines ~594-651).

Only grid's snapshot was regenerated, so yarn test:snapshots --group crud will fail. Regenerate the crud snapshot (yarn update:snapshots --group crud). This is the only other package whose snapshots embed a multi-level grid footer.
crud.test.snap.js:191 · test-coverage · confirmed

Comment thread packages/grid/src/vaadin-grid-column-rendering-mixin.js Outdated
Comment thread packages/grid/src/vaadin-grid-column-rendering-mixin.js Outdated
@vursen
vursen force-pushed the declarative-grid-header-footer-row-parts branch 2 times, most recently from cf99cb8 to d440d7b Compare July 24, 2026 09:32
@vursen

vursen commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

/code-review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

DOM snapshots changed because directive-rendered part attributes contain extra whitespace on initial render. Lit's classMap produces the same whitespace for class, but the snapshot library normalizes the class attribute and keeps part as is.

@vursen
vursen force-pushed the declarative-grid-header-footer-row-parts branch from d440d7b to e7ea1c2 Compare July 24, 2026 09:45
@vursen
vursen changed the base branch from main to add-part-map-directive July 24, 2026 09:45
@vursen

vursen commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

/code-review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the changes — left 3 comments.

Finding
🧹 #getHeaderRows and #getFooterRows are near-duplicate methods
🧹 findIndex/findLastIndex re-scan the rows array once per row inside the .map
cellParts is rebuilt for every cell though it is constant per row

Comment thread packages/grid/src/vaadin-grid-header-footer-rendering-mixin.js Outdated
Comment thread packages/grid/src/vaadin-grid-column-rendering-mixin.js Outdated
Comment thread packages/grid/src/vaadin-grid-header-footer-rendering-mixin.js
Base automatically changed from add-part-map-directive to main July 24, 2026 10:59
@vursen
vursen force-pushed the declarative-grid-header-footer-row-parts branch 2 times, most recently from c96d1e4 to 672c3e3 Compare July 24, 2026 11:56
@vursen
vursen force-pushed the declarative-grid-header-footer-row-parts branch 2 times, most recently from faadebc to c8f2f39 Compare July 24, 2026 12:47
@vursen

vursen commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

/code-review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the changes — left 2 comments.

Finding
_swapColumnOrders iterates all body rows twice instead of once.
🧹 Redundant literal space before partMap() bakes double/trailing spaces into the part attribute.

Comment thread packages/grid/src/vaadin-grid-column-reordering-mixin.js
Comment thread packages/grid/src/vaadin-grid-header-footer-rendering-mixin.js Outdated
@vursen
vursen force-pushed the declarative-grid-header-footer-row-parts branch from c8f2f39 to 15f9331 Compare July 24, 2026 13:25
Comment thread packages/grid/src/vaadin-grid-column-reordering-mixin.js
@vursen
vursen force-pushed the declarative-grid-header-footer-row-parts branch from 15f9331 to 0cdfe57 Compare July 24, 2026 14:14
@vursen
vursen force-pushed the declarative-grid-header-footer-row-parts branch 2 times, most recently from 700cf40 to aa5bd98 Compare July 24, 2026 14:17
@sonarqubecloud

Copy link
Copy Markdown

@vursen
vursen merged commit 539e492 into main Jul 24, 2026
10 checks passed
@vursen
vursen deleted the declarative-grid-header-footer-row-parts branch July 24, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants