This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23382 - <dialog>: dialog part of inert subtrees section is not clear
Summary: <dialog>: dialog part of inert subtrees section is not clear
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on: 23475
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-27 14:47 UTC by steve faulkner
Modified: 2014-01-02 20:54 UTC (History)
7 users (show)

See Also:


Attachments

Description steve faulkner 2013-09-27 14:47:29 UTC
+++ This bug was initially created as a clone of Bug #23381 +++

the spec says:

"An entire Document can be marked as blocked by a modal dialog subject. While a Document is so marked, every node that is in the Document, with the exception of the subject element, its ancestors, and its descendants, must be marked inert." 

http://www.w3.org/html/wg/drafts/html/master/editing.html#inert-subtrees

what should mean that everything but dialog, its ancestors and descendants must be inert. However if the dialog is part of the document then that everything includes no element.

Is "its ancestors" specified by mistake?
Comment 1 Ian 'Hixie' Hickson 2013-09-27 18:07:01 UTC
I don't understand. Can you elaborate?
Comment 2 alexander surkov 2013-09-27 18:39:38 UTC
I think I misread the spec but the way it's stated is still confusing.

Say I have the following markup:

<body>
  A web page content
  <dialog open="true">
    A dialog the user is supposed to operate with
  <dialog>
</body>

(if necessary we can pretend that dialogElm.showModal() has been called)

I I read the spec right then this is a case when document is marked as blocked by modal dialog. And then it should mean that everything but dialog, its ancestors and descendants must be inert. Since document itself is ancestor of dialog then the document shouldn't be inert. That means the document is allowed to take focus which looks unwanted.
Comment 3 Ian 'Hixie' Hickson 2013-09-27 21:20:13 UTC
>   <dialog open="true">

(It's a boolean attribute, so just open="" or open="open".)


> I I read the spec right then this is a case when document is marked as
> blocked by modal dialog. And then it should mean that everything but dialog,
> its ancestors and descendants must be inert. Since document itself is
> ancestor of dialog then the document shouldn't be inert. That means the
> document is allowed to take focus which looks unwanted.

If the Document is inert, then how can the <dialog>, which is in the Document, take focus? Inertness is like display:none, essentially.
Comment 4 steve faulkner 2013-09-28 08:03:23 UTC
(In reply to Ian 'Hixie' Hickson from comment #3)
> >   <dialog open="true">
> 
> (It's a boolean attribute, so just open="" or open="open".)
> 
> 
> > I I read the spec right then this is a case when document is marked as
> > blocked by modal dialog. And then it should mean that everything but dialog,
> > its ancestors and descendants must be inert. Since document itself is
> > ancestor of dialog then the document shouldn't be inert. That means the
> > document is allowed to take focus which looks unwanted.
> 
> If the Document is inert, then how can the <dialog>, which is in the
> Document, take focus? Inertness is like display:none, essentially.

so the text is misleading since it states

"An entire Document can be marked as blocked by a modal dialog subject. While a Document is so marked," 

An 'entire document' can never be marked as blocked by a modal dialog, as the modal is part of the document.

>Inertness is like display:none, essentially.

I am confused by this statement, can you elaborate?
Comment 5 alexander surkov 2013-09-30 12:05:37 UTC
(In reply to Ian 'Hixie' Hickson from comment #3)
> >   <dialog open="true">
> 
> (It's a boolean attribute, so just open="" or open="open".)
> 
> 
> > I I read the spec right then this is a case when document is marked as
> > blocked by modal dialog. And then it should mean that everything but dialog,
> > its ancestors and descendants must be inert. Since document itself is
> > ancestor of dialog then the document shouldn't be inert. That means the
> > document is allowed to take focus which looks unwanted.
> 
> If the Document is inert, then how can the <dialog>, which is in the
> Document, take focus? Inertness is like display:none, essentially.

I miss your point. The document isn't necessary inert because it's an ancestor of the dialog element (spec says that inert is everything but dialog itself, its content and elements from ancestor chain).
Comment 6 Ian 'Hixie' Hickson 2013-10-01 20:38:02 UTC
(Please trim content when using the "reply" function, there's no point just duplicating entire comments, it just makes the bugs harder to read.)

(In reply to steve faulkner from comment #4)
> 
> so the text is misleading since it states
> 
> "An entire Document can be marked as blocked by a modal dialog subject.
> While a Document is so marked," 
> 
> An 'entire document' can never be marked as blocked by a modal dialog, as
> the modal is part of the document.

"blocked by a modal dialog" is a separate term than "inert".


> > Inertness is like display:none, essentially.
> 
> I am confused by this statement, can you elaborate?

I just meant this in the way that something that's a child of a display:none element is forced to be hidden, in the same way that something that's a child of an inert node is forced to be inert. Don't worry about it.


(In reply to alexander surkov from comment #5)
> 
> I miss your point. The document isn't necessary inert because it's an
> ancestor of the dialog element (spec says that inert is everything but
> dialog itself, its content and elements from ancestor chain).

Right.


(In reply to alexander surkov from comment #2)
> That means the document is allowed to take focus which looks unwanted.

Why would it be unwanted?


I don't really understand the problem or what you are proposing to fix it.
Comment 7 alexander surkov 2013-10-02 19:03:13 UTC
(In reply to Ian 'Hixie' Hickson from comment #6)

> > "An entire Document can be marked as blocked by a modal dialog subject.
> > While a Document is so marked," 
> > 
> > An 'entire document' can never be marked as blocked by a modal dialog, as
> > the modal is part of the document.
> 
> "blocked by a modal dialog" is a separate term than "inert".

I think I agree with Steve that it sounds a bit confusing: a dialog blocks the document while the dialog is a part of that document, since that should mean the dialog blocks itself.

> (In reply to alexander surkov from comment #5)
> > 
> > I miss your point. The document isn't necessary inert because it's an
> > ancestor of the dialog element (spec says that inert is everything but
> > dialog itself, its content and elements from ancestor chain).
> 
> Right.
> 
> (In reply to alexander surkov from comment #2)
> > That means the document is allowed to take focus which looks unwanted.
> 
> Why would it be unwanted?

If a modal dialog is shown then the user can move the focus back to the document blocked by that dialog, it doesn't go with modal dialog concept: because the user shouldn't be able to interact with blocked document until the dialog is dismissed.

> I don't really understand the problem or what you are proposing to fix it.

I find the wording is rather confusing. I would state it otherwise saying that 'A document blocked by dialog means that the whole document is inert except the dialog and its content. So inertness would be unlike display:none but closer to visibility style.
Comment 8 Ian 'Hixie' Hickson 2013-10-03 18:59:17 UTC
> I think I agree with Steve that it sounds a bit confusing: a dialog blocks
> the document while the dialog is a part of that document, since that should
> mean the dialog blocks itself.

The term "blocked by a modal dialog" is just an opaque string that sets a bit on a Document object. I could rename it to "has a pineapple milkshake" and it wouldn't change the meaning of the specification. Do you have a suggestion for a term that you find less confusing? 


> > Why would it be unwanted?
> 
> If a modal dialog is shown then the user can move the focus back to the
> document blocked by that dialog, it doesn't go with modal dialog concept:
> because the user shouldn't be able to interact with blocked document until
> the dialog is dismissed.

I don't understand what you think moving the focus to the document means.

Random elements like <p> or <aside> or <dialog> don't get focused, only form controls get focused. (You'd never see a focus ring around the whole dialog, that wouldn't mean anything useful).

Documents, and <body>, don't get focused either.

When a <dialog> is shown modally, the currently focused element (assuming it's outside the <dialog>) gets blurred. Nothing explicitly gains focus (unless something in the dialog has autofocus=""). This is the same as a normal page load.


> I find the wording is rather confusing. I would state it otherwise saying
> that 'A document blocked by dialog means that the whole document is inert
> except the dialog and its content. So inertness would be unlike display:none
> but closer to visibility style.

I'm find with changing the wording in principle, but making inertness apply on a per-node basis rather than per-subtree basis would make things much harder to explain, IMHO.
Comment 9 alexander surkov 2013-10-07 17:54:49 UTC
(In reply to Ian 'Hixie' Hickson from comment #8)
> > I think I agree with Steve that it sounds a bit confusing: a dialog blocks
> > the document while the dialog is a part of that document, since that should
> > mean the dialog blocks itself.
> 
> The term "blocked by a modal dialog" is just an opaque string that sets a
> bit on a Document object. I could rename it to "has a pineapple milkshake"
> and it wouldn't change the meaning of the specification. Do you have a
> suggestion for a term that you find less confusing? 

I think term is descriptive. If you dig into then you may find it confusing but it doesn't necessary means a better term can be invented. At least I don't have good suggestions. Probably a small note about the term can be given in the spec.

> I don't understand what you think moving the focus to the document means.

it means document is focused (both DOM and user focus), in Firefox, for example when you tab into the document you can see a dotted border around the document

> Random elements like <p> or <aside> or <dialog> don't get focused, only form
> controls get focused. (You'd never see a focus ring around the whole dialog,
> that wouldn't mean anything useful).
> 
> Documents, and <body>, don't get focused either.

elements can take focus if @tabindex technique is used. It's probably an edge case but anyway.

> When a <dialog> is shown modally, the currently focused element (assuming
> it's outside the <dialog>) gets blurred. Nothing explicitly gains focus
> (unless something in the dialog has autofocus=""). This is the same as a
> normal page load.

The dialog can be the same as a normal page if @no autofocus is used and if bug 23366 will be not fixed. But in case of normal page load I think DOM document of the loaded page gets focused (no dotted border around it though). Probably we should define what focus term we use here (for example DOM focus vs user focus or something-else focus). I think I primarily rely on the user focus terms which in particular means if something gets blurred then something gets focused (aka focus is never lost).

> > I find the wording is rather confusing. I would state it otherwise saying
> > that 'A document blocked by dialog means that the whole document is inert
> > except the dialog and its content. So inertness would be unlike display:none
> > but closer to visibility style.
> 
> I'm find with changing the wording in principle, but making inertness apply
> on a per-node basis rather than per-subtree basis would make things much
> harder to explain, IMHO.

Honestly I don't see why it's harder to explain things but that would get rid of my concerns: when modal dialog is shown then something from the blocked document (i.e. elements in ancestor chain) is allowed to take the focus.
Comment 10 Ian 'Hixie' Hickson 2013-10-07 21:08:03 UTC
I'm going to wait until we figure out what we're doing with bug 23366 before trying to fix this, in case it changes some of the same text (which is looking likely at this point).
Comment 11 Ian 'Hixie' Hickson 2013-12-10 23:06:25 UTC
Make that bug 23475.
Comment 12 Ian 'Hixie' Hickson 2013-12-11 21:25:55 UTC
I've changed the spec to make "inertness" apply per-node as suggested above, and also made ancestors of <dialog>s get marked inert. Let me know if the spec is still confusing. Note that focus-related issues are going to be dealt with in bug 23475, separate from this one.
Comment 13 Matt Falkenhagen 2013-12-12 02:54:07 UTC
I'm trying to understand the implications of the change to make dialog's ancestors inert. Now if we have:

<body>
  <p>Inert paragraph</p>
  <dialog>Modal dialog</dialog>
</body>

and the user clicks on "Inert paragraph", what is the event fired on? It previously would have been <body>, but now <body> is inert. Is the event just dropped?

I'm wondering if it's feasible for me to implement this behavior until bug 23475 is worked out. Blink gives <body> the focus by default when nothing else has focus. It seems like it'll lead to bugs if <body> is inert and has default focus, e.g., if you open a modal <dialog> with no focusable controls. I'm not sure we can handle nothing at all having focus.

It's probably easier implementation-wise to just say <dialog> is always focusable, though I know that topic is what we've been discussing in bug 23475 and others for some time.
Comment 14 Ian 'Hixie' Hickson 2013-12-12 17:14:58 UTC
(In reply to Matt Falkenhagen from comment #13)
> I'm trying to understand the implications of the change to make dialog's
> ancestors inert. Now if we have:
> 
> <body>
>   <p>Inert paragraph</p>
>   <dialog>Modal dialog</dialog>
> </body>
> 
> and the user clicks on "Inert paragraph", what is the event fired on? It
> previously would have been <body>, but now <body> is inert. Is the event
> just dropped?

I guess the event gets fired on the Document or the Window (not sure which), same as if the Document doesn't have any nodes at all:

   http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2691

In Chrome, it's the Document.


> I'm wondering if it's feasible for me to implement this behavior until bug
> 23475 is worked out. Blink gives <body> the focus by default when nothing
> else has focus. It seems like it'll lead to bugs if <body> is inert and has
> default focus, e.g., if you open a modal <dialog> with no focusable
> controls. I'm not sure we can handle nothing at all having focus.

Yeah, bug 23475 is probably a pre-req to making this work 100%.
Comment 15 Ian 'Hixie' Hickson 2014-01-02 20:54:21 UTC
Marking FIXED per comment 12, please don't hesitate to reopen if you have a follow-up on comment 14 or some other question or issue with this bug.