Skip to content

The pending dialog stack and the stack of top layer #2268

Closed

Description

@upsuper

Currently, when calling showModal(), a dialog element would be added to both the pending dialog stack and the stack of the top layer. An element appearing in two stacks usually indicates potential problems as shown previous for having both the fullscreen element stack and the top layer. And there is problem for this as well, again.

The problem is that, when adding an element to the top layer which already presents there, it is moved to the top of the top layer (rather than a no-op), and there are currently (at least) two ways to add an element there, one is via adding the element to the pending dialog stack, the other is via fullscreen the element, so one can do something like:

  1. calling showModal() on dialog #a
  2. calling showModal() on dialog #b
  3. calling requestFullscreen() on dialog #a

After this, the stack of the top layer would be (from bottom to top) [#b, #a], while the pending dialog stack would be [#a, #b], which is unsync.

Even worse, the top layer renders in a way that the later an element is added, the higher its z-order would be, so in this case, user would actually see #a rather than #b, but every algorithm in the HTML spec which depends on the pending dialog stack treats #b as the current dialog.

In addition to the issue above, at that state, the document is considered to be blocked by dialog #b which makes the whole viewport non-operable because the fullscreened #a is inerted.

(Note that, the last issue happens whenever an element outside the current modal dialog enters fullscreen, no matter whether that element is another modal dialog.)

Given this, I suggest that we merge the pending dialog stack into the top layer, then use a flag to indicate that the element is a modal dialog, and change the blocked by a modal dialog concept to blocked by the top layer, which inerts everything outside the top element of the top layer.

(I think I, or someone else, should have filed a similiar issue before... but I didn't find it, so file again.)

cc @foolip @annevk @domenic

Activity

  1. domenic commented on Jan 17, 2017

    @domenic
    Member

    Thanks for finding this. I agree with your suggested change.

    Would you be able to help us by writing web platform tests covering the spec change? I.e. things that would behave differently with the current spec vs. with a spec that merged the two stacks.

    In particular, it seems like the change to inert everything outside the top layer would have noticeable impacts on fullscreen (e.g. you would no longer be able to tab around to non-fullscreened elements).

    It would be especially good to get @foolip's perspective as I believe he is still working on finishing up Blink's unprefixed fullscreen implementation.

  2. upsuper commented on Jan 20, 2017

    @upsuper
    MemberAuthor

    On Gecko side, @nt1m is currently implementing <dialog> support, and we already have top layer implementation for fullscreen, so there are questions about how we should handle their interaction.

    Blink already has <dialog> with top layer, and @foolip is currently working on fullscreen with top layer. I suppose he would also meet similiar issue when handling them?

    I'll try to write a test for that change.

  3. foolip commented on Jan 24, 2017

    @foolip
    Member

    Good catch, @upsuper! I haven't worked with <dialog> before, but it looks like Blink doesn't have a "pending dialog stack" at all, dialog.showModal() just pushes to the top layer. So having just top layer and flags for additional book keeping SGTM.

    But, what effect does being in the pending dialog stack actually have? Tests for this would be great to clarify. Regarding the inert stuff, I'm not sure how tabbing currently works in fullscreen, and would be unsurprised if there are problems :)

  4. self-assigned this
    on Feb 8, 2017
  5. domenic commented on Feb 8, 2017

    @domenic
    Member

    Based on testing of https://jsbin.com/fakivinege/3/edit?html in Chrome it seems like fullscreen does not make everything else on the page inert. I'm going to assume we want to keep that for now.

    I'll make things "blocked by a modal dialog" if there is a dialog in the top layer. The topmost dialog will be the one blocking.

    Again, help writing tests will be much appreciated. Spec PR coming soon.

  6. foolip commented on May 24, 2017

    @foolip
    Member

    In whatwg/fullscreen#91 we're thinking about making it impossible for dialog elements to go fullscreen, in which case strictly speaking no flags would be needed to distinguish why something is in top layer. However, that could be an optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions