Skip to content

Commit fb38129

Browse files
authored
fix: don't remove lazy-open registration on detach (#2738)
1 parent 689f189 commit fb38129

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

  • vaadin-combo-box-flow-parent

‎vaadin-combo-box-flow-parent/vaadin-combo-box-flow-integration-tests/src/main/java/com/vaadin/flow/component/combobox/test/DataProviderPage.java‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.vaadin.flow.component.html.Div;
2525
import com.vaadin.flow.component.html.Hr;
2626
import com.vaadin.flow.component.html.NativeButton;
27+
import com.vaadin.flow.component.html.Span;
2728
import com.vaadin.flow.data.provider.DataProvider;
2829
import com.vaadin.flow.data.provider.ListDataProvider;
2930
import com.vaadin.flow.router.Route;
@@ -90,6 +91,8 @@ private void createRefreshWithSmallerDataSet() {
9091
ComboBox<String> cb = new ComboBox<>();
9192
cb.setId("combo-box-with-reduce-data-set");
9293

94+
Span cbWrapper = new Span(cb);
95+
9396
List<String> items = new ArrayList<>();
9497
items.add("foo");
9598
items.add("bar");
@@ -106,6 +109,17 @@ private void createRefreshWithSmallerDataSet() {
106109
refreshAllWithSmallerDataSetButton
107110
.setId("refresh-all-with-smaller-data-set");
108111

109-
add(cb, refreshAllWithSmallerDataSetButton);
112+
NativeButton toggleAttachedButton = new NativeButton("Toggle attached",
113+
event -> {
114+
if (cb.isAttached()) {
115+
cbWrapper.remove(cb);
116+
} else {
117+
cbWrapper.add(cb);
118+
}
119+
});
120+
toggleAttachedButton.setId("toggle-attached");
121+
122+
add(cbWrapper, refreshAllWithSmallerDataSetButton,
123+
toggleAttachedButton);
110124
}
111125
}

‎vaadin-combo-box-flow-parent/vaadin-combo-box-flow-integration-tests/src/test/java/com/vaadin/flow/component/combobox/test/DataProviderIT.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,18 @@ public void loadData_refreshAllWithSmallerDataSet_correctItemsDisplayed() {
100100
"Item is not the same as in the refreshed data provider.",
101101
"bar", items.get(0));
102102
}
103+
104+
@Test
105+
public void loadData_toggleAttached_correctItemsDisplayed() {
106+
// Detach and reattach the combobox
107+
findElement(By.id("toggle-attached")).click();
108+
findElement(By.id("toggle-attached")).click();
109+
110+
// Open the popup
111+
ComboBoxElement comboBox = $(ComboBoxElement.class)
112+
.id("combo-box-with-reduce-data-set");
113+
comboBox.openPopup();
114+
115+
waitUntil(e -> "bar".equals(comboBox.getOptions().get(1)));
116+
}
103117
}

‎vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/java/com/vaadin/flow/component/combobox/ComboBox.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,6 @@ protected void onDetach(DetachEvent detachEvent) {
971971
dataProviderListener.remove();
972972
dataProviderListener = null;
973973
}
974-
removeLazyOpenRegistration();
975974

976975
if (clearFilterOnCloseRegistration != null) {
977976
clearFilterOnCloseRegistration.remove();

0 commit comments

Comments
 (0)