diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2021-03-08 13:18:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 13:18:11 +0200 |
commit | 7eb9588359c28ed484bcaeb729fc54675601671a (patch) | |
tree | c8aeb6d5f6b323ad277fe2266e6e574461a23d1a /server/src/main/java/com/vaadin | |
parent | ff41bba3d7d0d8c02570b8dfccb413295e091708 (diff) | |
download | vaadin-framework-7eb9588359c28ed484bcaeb729fc54675601671a.tar.gz vaadin-framework-7eb9588359c28ed484bcaeb729fc54675601671a.zip |
Fix updating Grid's item set when details rows are open. (#12231)
- Old details should close.
- New details should open.
- If some row has details in both old and new item set, the details row
contents should get updated.
- Updating details row contents should not break the positioning of the
rows and details below.
Fixes #12211
Diffstat (limited to 'server/src/main/java/com/vaadin')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Grid.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index ec891396e9..f84dbd40cb 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -4997,7 +4997,17 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, @Override protected void internalSetDataProvider(DataProvider<T, ?> dataProvider) { + boolean newProvider = getDataProvider() != dataProvider; super.internalSetDataProvider(dataProvider); + if (newProvider) { + Set<T> oldVisibleDetails = new HashSet<>( + detailsManager.visibleDetails); + oldVisibleDetails.forEach(item -> { + // close all old details even if the same item exists in the new + // provider + detailsManager.setDetailsVisible(item, false); + }); + } for (Column<T, ?> column : getColumns()) { column.updateSortable(); } |