Ensuring popup is on top

48 views
Skip to first unread message

Thomas Lefort

unread,
Nov 13, 2012, 8:05:04 AM11/13/12
to google-we...@googlegroups.com
I have a use case where I do need to show one dialog on top of the other. The problem is that those dialogs are reused across the application and if the one that should be on top for the use case happens to have been open (in another use case) before the one that should be below, it is not visible (covered by the other one) because (I believe) it was inserted in the DOM before.

Is there an obvious way of doing this? Currently, the two strategies I can think of to make sure the show method could always ensure that a dialog is on top of the others are the following:
- zindex, scanning the list of open popups and check for the higfhest zindex and setting the zindex of the one I am showing to zindex + 1
- detach/reattach the popup to the DOM.

I gave a quick try to the later one using the following code, which seems to work:
    @Override
    public void show() {
        Widget parent = getParent();
        if(parent instanceof Panel) {
            ((Panel) parent).remove(this);
            ((Panel) parent).add(this);
        }
        // blabla do the rest
    }

Any idea if this detach/reattach strategy can have any side effect?


David

unread,
Nov 13, 2012, 9:21:45 AM11/13/12
to google-we...@googlegroups.com
I would think that z-index is the better solution.  Your mechanism for opening the popup ( rather than the popup itself) should be the one making the determination as to which z-index to use.   
Beyond a "system error" type of message, I personally don't think it's good UX to have popups throwing popups... but a requirement is a requirement.
Reply all
Reply to author
Forward
0 new messages