Skip to content

Commit f961516

Browse files
committed
Dialog: Documenting the focus logic that the widget uses. Fixes #120.
(cherry picked from commit 6b282d0)
1 parent c868f60 commit f961516

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

entries/dialog.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@
99

1010
<p>A bottom button bar and semi-transparent modal overlay layer are common options that can be added.</p>
1111

12+
<h3>Focus</h3>
13+
14+
<p>Upon opening a dialog, focus is automatically moved to the first item that matches the following:</p>
15+
16+
<ol>
17+
<li>The first element within the dialog with the <code>autofocus</code> attribute</li>
18+
<li>The first <a href="/tabbable-selector/"><code>:tabbable</code></a> element within the dialog's content</li>
19+
<li>The first <a href="/tabbable-selector/"><code>:tabbable</code></a> element within the dialog's buttonpane</li>
20+
<li>The dialog's close button</li>
21+
<li>The dialog itself</li>
22+
</ol>
23+
24+
<p>While open, the dialog widget ensures that tabbing cycles focus between elements within the dialog itself, not elements outside of it. Modal dialogs additionally prevent mouse users from clicking on elements outside of the dialog.</p>
25+
26+
<p>Upon closing a dialog, focus is automatically returned to the element that had focus when the dialog was opened.</p>
27+
1228
<h3>Hiding the close button</h3>
1329

1430
<p>In some cases, you may want to hide the close button, for instance, if you have a close button in the button pane. The best way to accomplish this is via CSS. As an example, you can define a simple rule, such as:</p>
@@ -19,7 +35,7 @@
1935
}
2036
</code></pre>
2137

22-
<p>Then, you can simply add the <code>no-close</code> class to any dialog in order to hide it's close button:</p>
38+
<p>Then, you can simply add the <code>no-close</code> class to any dialog in order to hide its close button:</p>
2339

2440
<pre><code>
2541
$( "#dialog" ).dialog({

0 commit comments

Comments
 (0)