You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
vaadin.version 12.0.1
Setting the items to a previously-uninitialized ComboBox causes a client-side exception.
Simple demo that reproduces the issue:
public class MainView extends VerticalLayout {
public MainView() {
ComboBox<String> comboBox = new ComboBox<>();
Button button = new Button("Click me to add items to the combobox",
event -> comboBox.setItems("foo", "bar"));
add(comboBox, button);
}
}
Clicking the button causes a bunch of TypeErrors on the client side:
client-D1AD34905AC1AA5B4DBECA8FB0306D92.cache.js:197 (TypeError) : Cannot read property 'reset' of undefined
Workaround is to initialize the ComboBox with an empty Collection.
The text was updated successfully, but these errors were encountered:
Commit #188 should fix this. I adapted your example code @OlliTietavainenVaadin to have another button to test the code added.
public MainLayout() {
ComboBox<String> comboBox = new ComboBox<>();
// comboBox.setItems(Collections.emptyList());
Element e = comboBox.getElement();
while (e.getParent() != null)
e = e.getParent();
final Element ele = e;
Button button = new Button("Click me to run", event -> {
if (comboBox.getElement().getProperty("$connector") == null) {
ele.executeJavaScript("window.Vaadin.Flow.comboBoxConnector.initLazy($0);", comboBox.getElement());
}
});
Button button2 = new Button("Click me to add items to the combobox", event -> comboBox.setItems("foo", "bar"));
add(comboBox, button);
add(comboBox, button2);
}
Clicking the button to run the JS to initialize $connector seemed to fix the issue. The solution is kind of hack-y but works as far as I can tell.
vaadin.version 12.0.1
Setting the items to a previously-uninitialized ComboBox causes a client-side exception.
Simple demo that reproduces the issue:
Clicking the button causes a bunch of TypeErrors on the client side:
Workaround is to initialize the ComboBox with an empty Collection.
The text was updated successfully, but these errors were encountered: