vaadin / flow-components

Java counterpart of Vaadin Web Components
101 stars 66 forks source link

Dynamically created Popover does not open when used in Dialog #6840

Closed web-padawan closed 4 days ago

web-padawan commented 6 days ago

Description

Originally reported at https://vaadin.com/forum/t/popover-within-dialog/167818

When creating a Popover dynamically and calling open() without adding to the UI while the target is inside Dialog, the vaadin-popover instance is attached to vaadin-dialog-overlay but the opened property is not set to true.

Note: the problem occurs on first click. On subsequent clicks, new popover instance is added and opened.

Expected outcome

Expected Popover to open.

Minimal reproducible example

public class PopoverDialogPage extends Div {

    public PopoverDialogPage() {
        NativeButton button = new NativeButton("Show popover");
        button.addClickListener(evt -> {
            Popover popover = new Popover();
            popover.add("Sample popover text.");
            popover.setTarget(button);
            popover.open(); // Problem here: nothing happens.
        });
        Dialog dialog = new Dialog("Demo dialog", button);
        dialog.open();
    }
}

Steps to reproduce

Run the above code and click the button in the Dialog.

Environment

Vaadin version(s): 24.5, 24.6

Browsers

Issue is not browser related

web-padawan commented 6 days ago

UPD: looks related to Dialog modality since using dialog.setModal(false) make the popover open also on first click.