Skip to content

Commit 2078da1

Browse files
josepharharrubberyuzu
authored andcommitted
Allow top layer elements to be nested within popovers
This allows top layer elements, including the dialog element, to be nested inside of an open popover, by not closing the popover when the new top layer element is opened. Without this patch, opening a modal dialog inside of a popover will make the page inert and make the dialog invisible. Fixes whatwg#9998. See also whatwg/fullscreen#237.
1 parent 6abbb90 commit 2078da1

1 file changed

Lines changed: 63 additions & 24 deletions

File tree

source

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61386,8 +61386,14 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6138661386
<li><p>Set <span>this</span>'s <span>previously focused element</span> to the
6138761387
<span>focused</span> element.</p></li>
6138861388

61389-
<li><p>Run <span>hide all popovers</span> given <span>this</span>'s <span>node
61390-
document</span>.</p></li>
61389+
<li><p>Let <var>hideUntil</var> be the result of running <span>topmost popover ancestor</span>
61390+
given <span>this</span>, null, and false.</p></li>
61391+
61392+
<li><p>If <var>hideUntil</var> is null, then set <var>hideUntil</var> to <span>this</span>'s
61393+
<span>node document</span>.</p></li>
61394+
61395+
<li><p>Run <span data-x="hide-all-popovers-until">hide all popovers until</span> given
61396+
<var>hideUntil</var>, false, and true.</p></li>
6139161397

6139261398
<li><p>Run the <span>dialog focusing steps</span> given <span>this</span>.</p></li>
6139361399
</ol>
@@ -61449,8 +61455,14 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6144961455
<li><p>Set <span>this</span>'s <span>previously focused element</span> to the
6145061456
<span>focused</span> element.</p></li>
6145161457

61452-
<li><p>Run <span>hide all popovers</span> given <span>this</span>'s <span>node
61453-
document</span>.</p></li>
61458+
<li><p>Let <var>hideUntil</var> be the result of running <span>topmost popover ancestor</span>
61459+
given <span>this</span>, null, and false.</p></li>
61460+
61461+
<li><p>If <var>hideUntil</var> is null, then set <var>hideUntil</var> to <span>this</span>'s
61462+
<span>node document</span>.</p></li>
61463+
61464+
<li><p>Run <span data-x="hide-all-popovers-until">hide all popovers until</span> given
61465+
<var>hideUntil</var>, false, and true.</p></li>
6145461466

6145561467
<li><p>Run the <span>dialog focusing steps</span> given <span>this</span>.</p></li>
6145661468
</ol>
@@ -84925,7 +84937,7 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8492584937
data-x="attr-popover">popover</code> attribute.</p></li>
8492684938

8492784939
<li><p>Let <var>ancestor</var> be the result of running the <span>topmost popover
84928-
ancestor</span> algorithm given <var>element</var> and <var>invoker</var>.</p></li>
84940+
ancestor</span> algorithm given <var>element</var>, <var>invoker</var>, and true.</p></li>
8492984941

8493084942
<li><p>If <var>ancestor</var> is null, then set <var>ancestor</var> to
8493184943
<var>document</var>.</p></li>
@@ -85198,7 +85210,7 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8519885210
data-x="popover-showing-state">showing</span>; otherwise false.</p></li>
8519985211
</ol>
8520085212

85201-
<p>To <dfn data-x="hide-all-popovers-until">hide all popovers until</dfn>, given an <span
85213+
<p>To <dfn export data-x="hide-all-popovers-until">hide all popovers until</dfn>, given an <span
8520285214
data-x="HTML elements">HTML element</span> or <code>Document</code> <var>endpoint</var>, a boolean
8520385215
<var>focusPreviousElement</var>, and a boolean <var>fireEvents</var>:</p>
8520485216

@@ -85290,21 +85302,17 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8529085302
happens. For example, during light-dismiss of a popover, this algorithm ensures that we close only
8529185303
the popovers that aren't related to the node clicked by the user.</p>
8529285304

85293-
<p>To <dfn export>hide all popovers</dfn>, given a <code>Document</code> <var>document</var>, run
85294-
<span data-x="hide-all-popovers-until">hide all popovers until</span> given <var>document</var>,
85295-
false, and false.</p>
85296-
85297-
<p>To find the <dfn>topmost popover ancestor</dfn>, given a <code>Node</code>
85298-
<var>newPopover</var>, and an <span data-x="HTML elements">HTML element</span> or null
85299-
<var>invoker</var>, perform the following steps. They return an <span data-x="HTML
85300-
elements">HTML element</span> or null.</p>
85305+
<p>To find the <dfn export>topmost popover ancestor</dfn>, given a <code>Node</code>
85306+
<var>newPopoverOrTopLayerElement</var>, an <span data-x="HTML elements">HTML element</span> or
85307+
null <var>invoker</var>, and a boolean <var>isPopover</var>, perform the following steps. They
85308+
return an <span data-x="HTML elements">HTML element</span> or null.</p>
8530185309

8530285310
<div class="note">
8530385311
<p>The <span>topmost popover ancestor</span> algorithm will return the topmost (latest in the
85304-
<span>showing auto popover list</span>) ancestor popover for the provided popover. Popovers can
85305-
be related to each other in several ways, creating a tree of popovers. There are two paths
85306-
through which one popover (call it the "child" popover) can have a topmost ancestor popover (call
85307-
it the "parent" popover):</p>
85312+
<span>showing auto popover list</span>) ancestor popover for the provided popover or top layer
85313+
element. Popovers can be related to each other in several ways, creating a tree of popovers.
85314+
There are two paths through which one popover (call it the "child" popover) can have a topmost
85315+
ancestor popover (call it the "parent" popover):</p>
8530885316

8530985317
<ol>
8531085318
<li><p>The popovers are nested within each other in the node tree. In this case, the descendant
@@ -85322,14 +85330,45 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8532285330
containing an invoking element that points back to the containing popover), and it allows for the
8532385331
construction of a well-formed tree from the (possibly cyclic) graph of connections. Only <span
8532485332
data-x="attr-popover-auto-state">auto</span> popovers are considered.</p>
85333+
85334+
<p>If the provided element is a top layer element such as a <code>dialog</code> which is not
85335+
showing as a popover, then <span>topmost popover ancestor</span> will only look in the node tree
85336+
to find the first popover.</p>
8532585337
</div>
8532685338

8532785339
<ol>
85340+
<li>
85341+
<p>If <var>isPopover</var> is true:</p>
85342+
85343+
<ol>
85344+
<li><p><span>Assert</span>: <var>newPopoverOrTopLayerElement</var> is an <span data-x="HTML
85345+
elements">HTML element</span>.</p></li>
85346+
85347+
<li><p><span>Assert</span>: <var>newPopoverOrTopLayerElement</var>'s <code
85348+
data-x="attr-popover">popover</code> attribute is not in the <span
85349+
data-x="attr-popover-none-state">no popover state</span> or the <span
85350+
data-x="attr-popover-manual-state">manual</span> state.</p></li>
85351+
85352+
<li><p><span>Assert</span>: <var>newPopoverOrTopLayerElement</var>'s <span>popover visibility
85353+
state</span> is not in the <span data-x="popover-showing-state">popover showing
85354+
state</span>.</p></li>
85355+
</ol>
85356+
</li>
85357+
85358+
<li>
85359+
<p>Otherwise:</p>
85360+
85361+
<ol>
85362+
<li><p><span>Assert</span>: <var>invoker</var> is null.</p></li>
85363+
</ol>
85364+
</li>
85365+
8532885366
<li><p>Let <var>popoverPositions</var> be an empty <span>ordered map</span>.</p></li>
8532985367

8533085368
<li><p>Let <var>index</var> be 0.</p></li>
8533185369

85332-
<li><p>Let <var>document</var> be <var>newPopover</var>'s <span>node document</span>.</p></li>
85370+
<li><p>Let <var>document</var> be <var>newPopoverOrTopLayerElement</var>'s <span>node
85371+
document</span>.</p></li>
8533385372

8533485373
<li>
8533585374
<p>For each <var>popover</var> of <var>document</var>'s <span>showing auto popover
@@ -85343,8 +85382,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8534385382
</ol>
8534485383
</li>
8534585384

85346-
<li><p><span data-x="map set">Set</span> <var>popoverPositions</var>[<var>newPopover</var>] to
85347-
<var>index</var>.</p></li>
85385+
<li><p>If <var>isPopover</var> is true, then <span data-x="map set">set</span>
85386+
<var>popoverPositions</var>[<var>newPopoverOrTopLayerElement</var>] to <var>index</var>.</p></li>
8534885387

8534985388
<li><p>Increment <var>index</var> by 1.</p></li>
8535085389

@@ -85372,12 +85411,12 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8537285411
</ol>
8537385412
</li>
8537485413

85375-
<li><p>Run <var>checkAncestor</var> given <var>newPopover</var>'s parent node within the
85376-
<span>flat tree</span>.</p></li>
85414+
<li><p>Run <var>checkAncestor</var> given <var>newPopoverOrTopLayerElement</var>'s parent node
85415+
within the <span>flat tree</span>.</p></li>
8537785416

8537885417
<li><p>Run <var>checkAncestor</var> given <var>invoker</var>.</p></li>
8537985418

85380-
<li><p>return <var>topmostPopoverAncestor</var>.</p></li>
85419+
<li><p>Return <var>topmostPopoverAncestor</var>.</p></li>
8538185420
</ol>
8538285421

8538385422
<p>To find the <dfn>nearest inclusive open popover</dfn> given a <code>Node</code>

0 commit comments

Comments
 (0)