Skip to content

perf: reuse rowspan hosts during vertical scrolling - #1349

Merged
ghiscoding merged 2 commits into
masterfrom
bugfix/rowspan-perf
Nov 12, 2026
Merged

ghiscoding merged 2 commits into
masterfrom
bugfix/rowspan-perf

Conversation

@ghiscoding

@ghiscoding ghiscoding commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Reduce unnecessary DOM work when scrolling grids with tall rowspans by retaining cached span hosts as covered rows enter the viewport.

Why

Previously, rendering covered rows could remove and recreate an existing rowspan host, causing avoidable DOM churn during vertical scrolling.

Changes

  • Reuse cached rowspan hosts during rendering.
  • Update retained offscreen hosts when horizontal scrolling exposes new columns.
  • Add unit and Cypress regression coverage for host retention, horizontal rendering, and span stacking over active and hovered rows.

Validation

  • npm run build passed, including lint and type generation.
  • Core grid unit tests: 409 passed.
  • Example 0032 rowspan Cypress spec in headless Chrome: 48 passed.
  • git diff --check passed.

Comments

Adapted from slickgrid-universal PR #2932. No benchmark was run for this repository.

Benchmark

In headless Chrome, an 80-step, 2,400px scroll through Slickgrid-Universal Vanilla Example 33 produced:

Measurement Before After
Tall rowspan host removals 59 0
Tall rowspan host insertions 60 0
Rows left rendered 42 42

Three runs after the fix all had zero host removals or insertions. They averaged about 17.1 ms per animation-frame step. Frame timings were not recorded before the fix, so the benchmark does not quantify a speedup.

AI / LLM assistance

  • AI / LLM assistance used:
    • No
    • Yes
  • If Yes:
    • which tool/model: OpenAI ChatGPT Astra and Terra
    • how was it used: Adapted the fork's implementation and tests to this repository and ran validation.

Checklist

  • The changes are limited to only one scope.
  • Tests were added or updated where appropriate.
  • Documentation was updated where appropriate.

@ghiscoding

Copy link
Copy Markdown
Collaborator Author

@6pac can you ask Claude @6pac-ai to review this PR before merging, if anything needs change, fix it directly. Thanks

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.41%. Comparing base (9cc7dd0) to head (76a58a6).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1349   +/-   ##
=======================================
  Coverage   93.41%   93.41%           
=======================================
  Files          34       34           
  Lines       13519    13524    +5     
  Branches     4091     4093    +2     
=======================================
+ Hits        12629    12634    +5     
  Misses        686      686           
  Partials      204      204           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Avoids an includes() lookup per cached span host when gathering the rows
whose cells are cleaned up and rendered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@6pac-ai 6pac-ai 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.

Looks good, approving. I pushed one small follow-up, 76a58a6. It collects the rows to process in a Set, so we no longer call includes() on the array for every cached span host. Behaviour is unchanged.

Verification

  • Vitest: 1572/1572 pass, and the build and tsc --noEmit are clean.
  • Cypress: these specs pass, 159/159 on 21b5fbd, and 0032 again after the follow-up:
    • 0031 and 0032
    • colspan
    • pinning-rows
    • row-detail-selection-and-move
    • variable-row-height-spans
    • example16-row-detail
    • quirk-rowspan-stacking
  • The mandatory-rows unit test changed from 48 to 54 cells. I checked that the 6 extra cells are host row 2's and contain no duplicates.

Benchmark (example 0032, 80 vertical steps of 30px)

  • master: 83 host rows removed and 80 re-added
  • this PR: 4 removed and 1 added
  • Both end with the same 44 rendered rows.

Bonus fix: after a vertical scroll followed by a horizontal scroll, master is missing cells l15–l21 on host row 8. This PR renders them.

Not caused by this PR: rows that intersect a rowspan keep the cells to the left of the horizontal range, because cleanUpCells is skipped for those rows. master does the same. It could be looked at separately.

Minor: the getEditController()?.cancelCurrentEdit() change in the spec is unrelated, but harmless.

@ghiscoding
ghiscoding merged commit 523891c into master Nov 12, 2026
6 checks passed
@ghiscoding
ghiscoding deleted the bugfix/rowspan-perf branch November 12, 2026 14:40
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.

2 participants