henrikerola / PopupButton

Vaadin Add-on
http://vaadin.com/addon/popupbutton
7 stars 24 forks source link

Popup doesn´t close after click #27

Closed AlexZilch closed 10 years ago

AlexZilch commented 10 years ago

I have a PopupButton with two Buttons in the popup. Clicking on the Update button opens a modal dialogue and the Popup should be closed but it only closes after i clicked on the dialogue.

issue screenshot

Any suggestions for this?

My example code:

@Theme("popupbuttonexample") public class PopupbuttonexampleUI extends UI {

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = PopupbuttonexampleUI.class,    widgetset = "com.example.popupbuttonexample.widgetset.PopupbuttonexampleWidgetset")
public static class Servlet extends VaadinServlet {
}

@Override
protected void init(VaadinRequest request) 
{
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);

    final PopupButton popupBtn = initPopupButton();
    popupBtn.setImmediate(true);
    layout.addComponent(popupBtn);
}

public PopupButton initPopupButton()
{
    final PopupButton btnAction = new PopupButton("More");
    final VerticalLayout popupLayout = new VerticalLayout();

    Button btnUpload = new Button("Upload");
    btnUpload.setSizeFull();
    btnUpload.addClickListener(new Button.ClickListener() 
    {
        private static final long   serialVersionUID    = 6738013877778003854L;
        @Override
        public void buttonClick(ClickEvent event) 
        {           
            ExampleDialog dialog = new ExampleDialog();
            UI.getCurrent().addWindow(dialog);
        }
    });     
    Button btnEditMetadata = new Button("Edit Metadata");
    btnEditMetadata.setSizeFull();
    btnEditMetadata.addClickListener(new Button.ClickListener() 
    {
        private static final long   serialVersionUID    = 6738013877778003854L;

        @Override
        public void buttonClick(ClickEvent event) 
        {

        }
    });
    popupLayout.addComponents(btnUpload, btnEditMetadata);
    btnAction.setContent(popupLayout);      
    return btnAction;
}

public class ExampleDialog extends Window { private static final long serialVersionUID = -3143801528395534090L;

private Label       lblHeader;
private TextField   txtTest;
private Button      btnCancel;

public ExampleDialog()
{
    this.buildLayout();

    this.setModal(true);

    this.setHeight(300, Unit.PIXELS);
    this.setWidth(800, Unit.PIXELS);

    this.txtTest.focus();
}

private void buildLayout()
{       
    final VerticalLayout rootLayout = new VerticalLayout();
    lblHeader = new Label("My modal test window");

    txtTest = new TextField();
    txtTest.setSizeFull();

    btnCancel = new Button("Close");
    btnCancel.addClickListener(new Button.ClickListener()
        {
            private static final long   serialVersionUID    = -7233519982791254596L;

            @Override
            public void buttonClick(ClickEvent event) {
                ExampleDialog.this.close();
            }
        }
    );

    rootLayout.addComponents(lblHeader, txtTest, btnCancel);

    this.setContent(rootLayout);
}

void cancelClicked()
{
    this.close();
}

}

Thanks in advance

-Alex

henrikerola commented 10 years ago

Problem seems to be that you have a modal curtain that blocks clicking the button. Maybe you should close the popup button popup programmatically?

AlexZilch commented 10 years ago

While trying to close it programmatically i noticed that my WildFly didn´t republish the project. After fixing this problem the popup closed with setPopupVisible(false). Still thanks for your answer.