Skip to content

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

Open
vursen wants to merge 1 commit intomainfrom
fix/grid-selection-render-optimization
Open

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

Conversation

@vursen
Copy link
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 link
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
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.

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