Skip to content

Commit

Permalink
Move the focus to the previously focused element for dialog.close()
Browse files Browse the repository at this point in the history
Add a new `previously focused` element to dialog as a pointer
to the current focused element when `dialog.showModal()` and
`dialog.show()` are called, such that `dialog.close()` can
use it to restore the focus.

See #5678 for more details.
  • Loading branch information
sefeng211 committed Mar 25, 2021
1 parent 2a1c38f commit 8959353
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -57498,6 +57498,8 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
<li><p>Add an <code data-x="attr-dialog-open">open</code> attribute to the <code>dialog</code>
element, whose value is the empty string.</p></li>

<li><p>Set the <span>previously focused</span> element of the element to the <span>focused</span> element.</p></li>

<li><p>Run the <span>dialog focusing steps</span> for the <code>dialog</code> element.</p></li>
</ol>

Expand Down Expand Up @@ -57537,6 +57539,8 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
data-x="top-layer-add">add</span> <var>subject</var> to <var>subject</var>'s <span>node
document</span>'s <span>top layer</span>.</p></li>

<li><p>Set the <span>previously focused</span> element of <var>subject</var> to the <span>focused</span> element.</p></li>

<li><p>Run the <span>dialog focusing steps</span> for <var>subject</var>.</p></li>
</ol>

Expand Down Expand Up @@ -57610,6 +57614,10 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
<li><p>If <var>subject</var> is in its <code>Document</code>'s <span>top layer</span>, then <span
data-x="list remove">remove</span> it.</p></li>

<li><p>If the <span>previously focused</span> element is not null, run the
<span>focusing steps</span> for it, and set it to null; Don't scroll the viewport if the
element is outside the viewport.</p></li>

<li><p><span>Queue an element task</span> on the <span>user interaction task source</span> given the
<var>subject</var> element to <span data-x="concept-event-fire">fire an event</span> named
<code data-x="event-close">close</code> at <var>subject</var>.</p></li>
Expand Down Expand Up @@ -57644,6 +57652,11 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
<p>Each <code>dialog</code> element has an <dfn>is modal</dfn> flag. When a <code>dialog</code>
element is created, this flag must be set to false.</p>

<p>Each <code>dialog</code> element has a <dfn>previously focused</dfn> element which the default
is null. When <code data-x="dom-dialog-showModal">showModal()</code> and
<code data-x="dom-dialog-show">show()</code> are called, this element must be set to the currently
<span>focused</span> element before running the <span>dialog focusing steps</span>.</p>

<hr>

<p>The <dfn attribute for="HTMLDialogElement"><code data-x="dom-dialog-open">open</code></dfn> IDL
Expand Down

0 comments on commit 8959353

Please sign in to comment.