Skip to content

fix: use targeted item refresh when signal-bound item value changes#23913

Merged
Artur- merged 13 commits intomainfrom
dataview-proper-refresh
Mar 17, 2026
Merged

fix: use targeted item refresh when signal-bound item value changes#23913
Artur- merged 13 commits intomainfrom
dataview-proper-refresh

Conversation

@Artur-
Copy link
Member

@Artur- Artur- commented Mar 17, 2026

Thread old item identity through DataRefreshEvent so that KeyMapper can remap keys when an item is replaced with a new instance (different identity). This replaces the refreshAll() workaround with a targeted single-item refresh for signal-bound grid items.

Fixes vaadin/flow-components#8938

Thread old item identity through DataRefreshEvent so that KeyMapper can
remap keys when an item is replaced with a new instance (different
identity). This replaces the refreshAll() workaround with a targeted
single-item refresh for signal-bound grid items.

Fixes #8938
@Artur- Artur- requested a review from Legioth March 17, 2026 09:19
@github-actions
Copy link

github-actions bot commented Mar 17, 2026

Test Results

 1 388 files  +1   1 388 suites  +1   1h 28m 43s ⏱️ +49s
 9 925 tests +2   9 854 ✅ +2  71 💤 ±0  0 ❌ ±0 
10 398 runs  +2  10 318 ✅ +2  80 💤 ±0  0 ❌ ±0 

Results for commit e28fefb. ± Comparison against base commit 7891d15.

♻️ This comment has been updated with latest results.

- Rename refreshWithOldData to refresh overload for clarity
- Replace "threading" terminology with clearer wording in javadocs
- Simplify handleDataRefreshEvent to always use refresh(item, oldItem)
- Make DataKeyMapper.refresh(T, T) throw instead of silently discarding
- Add item swap in HierarchicalDataCommunicator cache context
- Add key reuse assertion in KeyMapperTest
- Fix spotless formatting
@Artur- Artur- requested a review from Legioth March 17, 2026 09:59
- Move rootCache context update into Cache.refreshItem(T, T) to avoid
  memory leaks and keep remapping logic encapsulated
- Update indexToItemId mapping when item identity changes
- Fix AbstractLazyDataViewTest to verify two-arg refresh calls
@Artur- Artur- requested a review from Legioth March 17, 2026 11:03
- Remove Cache.refreshItem(T, T) identity-changing overload
- HierarchicalDataCommunicator.refresh(T, T) throws when identities
  differ, deferring TreeGrid bindItems support to a future change
- AbstractDataView.replaceItem throws for non-AbstractDataProvider
- DataViewUtils throws for non-AbstractDataView signal bindings
- Add DataProvider.replaceItem(T oldItem, T newItem) as default method
- Add DataView.replaceItem(T oldItem, T newItem) to the interface
- Make DataRefreshEvent.getOldItem() public
- AbstractDataProvider overrides replaceItem to fire event with old item
- AbstractDataView.replaceItem delegates to DataProvider.replaceItem
- Remove all instanceof checks from DataViewUtils and AbstractDataView
Swap parameter order in DataKeyMapper.refresh, KeyMapper.refresh,
and DataCommunicator.refresh to match the (oldItem, newItem)
convention used by DataProvider.replaceItem and DataView.replaceItem.
Artur- added 2 commits March 17, 2026 12:32
Align replaceItem methods with the refresh/DataRefreshEvent convention
where the new/primary item is always the first parameter.
Artur- added 2 commits March 17, 2026 12:58
Align DataKeyMapper.refresh, KeyMapper.refresh, DataCommunicator.refresh,
and HierarchicalDataCommunicator.refresh with the convention where the
new/primary item is always the first parameter, matching refresh(T data)
and replaceItem(T newItem, T oldItem).
Artur- added 2 commits March 17, 2026 13:21
Without this override, the default DataProvider.replaceItem
falls back to refreshItem, losing the old item identity.
Use refreshItem(T newItem, T oldItem) as an overload of the existing
refreshItem(T item), keeping naming consistent within DataProvider
and DataView.
@Artur- Artur- requested a review from Legioth March 17, 2026 13:30
@Artur- Artur- marked this pull request as ready for review March 17, 2026 13:39
@Artur- Artur- enabled auto-merge (squash) March 17, 2026 13:46
@sonarqubecloud
Copy link

@Artur- Artur- merged commit bdc57be into main Mar 17, 2026
32 checks passed
@Artur- Artur- deleted the dataview-proper-refresh branch March 17, 2026 14:22
vaadin-bot pushed a commit that referenced this pull request Mar 17, 2026
…23913)

- Add a two-argument `refreshItem(T newItem, T oldItem)` overload to `DataProvider`, `DataView`, and related classes, enabling targeted refresh when an item's identity changes (e.g., signal-bound items replaced with new instances)
- `DataRefreshEvent` now carries an optional old item reference via `getOldItem()`, allowing`DataCommunicator` and `KeyMapper` to remap from the old identity to the new one instead of failing to find the item
- `HierarchicalDataCommunicator` throws `UnsupportedOperationException` for identity-changing refreshes, deferring TreeGrid `bindItems` support to a future change

Fixes #8938
Artur- added a commit that referenced this pull request Mar 18, 2026
…23913) (#23922)

- Add a two-argument `refreshItem(T newItem, T oldItem)` overload to `DataProvider`, `DataView`, and related classes, enabling targeted refresh when an item's identity changes (e.g., signal-bound items replaced with new instances)
- `DataRefreshEvent` now carries an optional old item reference via `getOldItem()`, allowing`DataCommunicator` and `KeyMapper` to remap from the old identity to the new one instead of failing to find the item
- `HierarchicalDataCommunicator` throws `UnsupportedOperationException` for identity-changing refreshes, deferring TreeGrid `bindItems` support to a future change

Fixes #8938

Co-authored-by: Artur Signell <artur@vaadin.com>
mshabarov added a commit that referenced this pull request Mar 18, 2026
mshabarov added a commit that referenced this pull request Mar 18, 2026
vaadin-bot pushed a commit that referenced this pull request Mar 18, 2026
mshabarov added a commit that referenced this pull request Mar 18, 2026
mshabarov added a commit that referenced this pull request Mar 19, 2026
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.

grid.bindItems(SharedListSignal) does not update rows when child value signal changes

3 participants