DominoKit / domino-ui

Domino-ui
Apache License 2.0
218 stars 44 forks source link

reopening the same dialog has weird visual effect #816

Closed howudodat closed 1 year ago

howudodat commented 1 year ago

Describe the bug re-opening the same dialog will sometimes create an unusual visual effect. Sometimes it shows partially behind another element.

To Reproduce Using the code below, click on the field to open the dialog, then close it, then click on the field again.

Expected behavior The dialog should probably have a z-index of top prior to becoming visible

    public class PickerBox extends TextBox {
        protected DlgPicker modal = null;

        public PickerBox(String sPlaceholder) {
            this.addClickListener(l->{ open(); });
            this.setPlaceholder(sPlaceholder);
            this.setLabel(" ");
        }

        protected void open() {
            if (modal == null) {
                this.modal = new DlgPicker();
            }

            modal.open();
        }

        protected class DlgPicker extends Dialog { 
            protected DivElement header = div().addCss(dui_flex, dui_flex_row);
            protected DivElement content = div().addCss(dui_flex, dui_flex_row);
            public DlgPicker() {
                super();
                init(this);
                setStretchWidth(DialogSize.MEDIUM);
                setStretchHeight(DialogSize.VERY_LARGE);
                setAutoClose(false);
                initHeader();
                initContent();
            }

            protected void initHeader() {
                NavBar nav = NavBar.create().addCss(dui_dialog_nav);
                nav.setTitle("Test");
                getHeader().appendChild(nav);
                nav.appendChild(PostfixAddOn.of((Icons.close().clickable().addClickListener(e -> onOk()))));
            }

            protected void initContent() {
                AutoVScrollPanel sp = AutoVScrollPanel.create()
                    .addCss(dui_w_full)
                    .setHeight("calc(100vh - 250px)");      

                for (int x=1; x<25; x++) {
                    MySwitchButton sb = new MySwitchButton("Test "+x);
                    sb.addClickListener(l->onRow(sb));
                    sp.appendChild(sb);
                }
                content.appendChild(sp);
                this.getContentBody().appendChild(content);
            }

            protected void onRow(MySwitchButton sb) {
                this.close();
            }
            protected void onOk() {
                this.close();
            }
        }

        protected class MySwitchButton extends SwitchButton {
            public MySwitchButton(String label) {
                super();
                setOffTitle(label);
                addCss(dui_flex, dui_w_full, dui_hide_label);
                getOffLabelElement().element().addCss(dui_flex, dui_grow_1);
                this.style().setCssProperty("border-bottom", "solid");
            }
        }

    }
    public void onModuleLoad() {
        mainApp = AppLayout.create("SDCP Mobile").show();
        DomGlobal.document.body.appendChild(mainApp.element());
        mainApp.getBody().appendChild(new PickerBox("Test"));

Screenshots 4272 4273

Screencast from 08-17-2023 03:35:53 PM.webm Screencast from 08-17-2023 03:38:31 PM.webm Screenshot from 2023-08-17 15-37-41

vegegoku commented 1 year ago

Could not reproduce with the attached sample.