GwtMaterialDesign / gwt-material

A Google Material Design wrapper for GWT
https://gwtmaterialdesign.github.io/gmd-core-demo/
Apache License 2.0
411 stars 124 forks source link

Items in MaterialListBox do not display the first time #19

Closed jkubiszewski closed 9 years ago

jkubiszewski commented 9 years ago

Items in MaterialListBox do not display the first time.

kevzlou7979 commented 9 years ago

Hi,

Please submit your code so that we can reproduce you error.

Best Regards, Kevin

jkubiszewski commented 9 years ago

I wrote sample code. It should illustrate what the problem is. MaterialListBox not updated after the addition of items.

import gwt.material.design.client.ui.MaterialListBox;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class Test implements EntryPoint {

  private MaterialListBox listBox;

  public void onModuleLoad() {
    listBox = new MaterialListBox();
    listBox.addItem("First");
    listBox.addItem("Second");
    listBox.addItem("Third");
    listBox.addItem("Fourth");
    listBox.addItem("Fifth");

    Button button = new Button("Add Six");
    button.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        listBox.addItem("Six");
      }
    });

    VerticalPanel panel = new VerticalPanel();
    panel.setSpacing(10);
    panel.add(listBox);
    panel.add(button);

    RootPanel.get("gwtContainer").add(panel);

  }
}
kevzlou7979 commented 9 years ago

Ok we just solved the issue, we digged into the Material ListBox it seems its not reupdating the items when you call addItem(). Now we fixed it by calling onInitMaterialListBox() once the user add an item.

jkubiszewski commented 9 years ago

Thanks! Great Job :)