Skip to content

refactor!: only re-render affected rows on grid selection change#11397

Merged
vursen merged 1 commit intomainfrom
fix/grid-selection-render-optimization
Mar 23, 2026
Merged

refactor!: only re-render affected rows on grid selection change#11397
vursen merged 1 commit intomainfrom
fix/grid-selection-render-optimization

Conversation

@vursen
Copy link
Copy Markdown
Contributor

@vursen vursen commented Mar 20, 2026

The PR optimizes __selectedItemsChanged in SelectionMixin to only call __updateRow on rows whose selection state actually changed, instead of triggering a full content update for all rendered rows.

Before After
Screenshot 2026-03-20 at 20 22 29 Screenshot 2026-03-20 at 20 22 01
Selection click: ~100 ms Selection click: ~4 ms

@vursen vursen changed the title fix: only re-render affected rows on grid selection change refactor: only re-render affected rows on grid selection change Mar 20, 2026
Instead of requesting a full content update when selectedItems changes,
only update the rows whose selection state actually changed. This avoids
unnecessary re-rendering of all visible rows when selecting or
deselecting a single item.
@vursen vursen force-pushed the fix/grid-selection-render-optimization branch from 52e6f06 to 00d7c0b Compare March 20, 2026 16:31
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess there can be use-cases where value on some cells depend on the grid's selection state

Kapture.2026-03-21.at.14.12.40.mp4

Copy link
Copy Markdown
Contributor Author

@vursen vursen Mar 21, 2026

Choose a reason for hiding this comment

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

I think it should be the developer's responsibility to ensure renderers get triggered when selection changes. They could, for example, accomplish that by adding selectedItems to the renderer's deps:

.renderer="${bodyRenderer(() => `${selectedItems.length} selected`, [selectedItems])}"

The fact that all renderers were automatically re-rendered on selection looks like an unintended side effect to me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree about it being the developer's responsibility, but since it has worked without additional wiring until now, changing it may cause some breakages. I'm not against the change, ideally something like this would be done for a new major though.

@vursen vursen changed the title refactor: only re-render affected rows on grid selection change refactor!: only re-render affected rows on grid selection change Mar 23, 2026
@vursen vursen merged commit 84e5529 into main Mar 23, 2026
10 checks passed
@vursen vursen deleted the fix/grid-selection-render-optimization branch March 23, 2026 12:09
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