Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown doesn't display when switching from setEnabled(false) to setEnabled(true) #103

Open
paodb opened this issue Apr 4, 2022 · 2 comments

Comments

@paodb
Copy link

paodb commented Apr 4, 2022

If I initialize the combobox with setEnabled(false), when trying to switch to setEnabled(true), the dropdown is not displaying. Here's an example to reproduce the issue:

Button toggleButton = new Button("Toggle combobox status");
MultiselectComboBox<User> combobox = new MultiselectComboBox<User>("Combo");

toggleButton.addClickListener(e -> {
    combobox.setEnabled(!combobox.isEnabled()); 
});

combobox.setEnabled(false);
combobox.setItems(List.of(new User("1", "Jane"), new User("2", "John")));
combobox.setItemLabelGenerator(User::getName);

add(toggleButton, combobox);

Vaadin version: 23.0.1
Component version: 4.0.0-rc2

@vexa
Copy link

vexa commented Jul 22, 2022

This issue is also relevant for me and i hope this will fix very soon.

@vexa
Copy link

vexa commented Jul 22, 2022

I have an Solution that works for me. The trick is that the webcomponent calls Client Callable when it is Ready.
First i set the enabled state to true. This is needed that the Component renders correct. Wehn the Component is ready in Dom i set the Enabeld state.

`public class MultiselectComboBoxExt extends MultiselectComboBox implements HasLabel {

private boolean enabledState;
private boolean attached = false;

public MultiselectComboBoxExt() {
super.setEnabled(true);
}

@OverRide
public void setEnabled(boolean enabled) {
if (!attached) {
enabledState = enabled;
} else {
super.setEnabled(enabled);
}
}

@ClientCallable
private void notifyReady() {
this.getElement().executeJs("$0.$connector.initDataConnector()", new Serializable[0]);
attached = true;
setEnabled(enabledState);
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants