-
Notifications
You must be signed in to change notification settings - Fork 3k
Implement dialog initial focus proposal #8199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2394e21
fd9c31d
b52e9b6
8da9666
2070d76
50c821f
844c49f
c15e1fc
4727fc0
8ff0298
da545c2
7003f1f
1ca7cbb
7dae27e
5907549
b09e68c
136592c
1f0a278
c6de43e
e4046aa
f60b5e2
3f56f1f
000aea4
30683ac
c95c97b
133d817
76ed03e
572a1c8
7585ed6
9fe975a
ca5d8e9
1763b9c
ee1a835
b9c63ca
494d638
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This implements the changes proposed here: https://github.com/whatwg/html/wiki/dialog--initial-focus,-a-proposal#dialog-draft-text Specifically: 1. Add a parameter to dialog.show() called preventInitialFocus, which prevents the dialog focusing steps from running. 2. Make the dialog focusing steps look at sequentially focusable elements instead of any focusable element. There are additional open issues around dialog initial focus listed here: #4184 (comment) TODO add a conformance requirement about autofocus: #7709 TODO consider adding a <p class=XXX> for tab trapping: #7707
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59158,7 +59158,7 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> { | |
|
|
||
| [<span>CEReactions</span>] attribute boolean <span data-x="dom-dialog-open">open</span>; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry, this is totally on me, but I forgot why we changed this from the example at https://github.com/whatwg/html/wiki/dialog--initial-focus,-a-proposal#example . @scottaohara I vaguely remember you being involved? I'm not very happy with this example because it's just hard to believe the web developer would put the button before the input. The example at https://github.com/whatwg/html/wiki/dialog--initial-focus,-a-proposal#example is more believable. If there's something wrong with my initial version (I vaguely recall there was), could we try to come up with a more believable example here?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I found the conversation. It's at #8199 (comment) (collapsed by default). I guess @annevk didn't like the example because it relied on the focusablity of readonly controls? I don't think that's so strange. The point of readonly (as opposed to disabled) is explicitly to be focusable/selectable. E.g. it's what I use in the second textbox in https://domenic.github.io/rewrapper/ . @annevk , are you OK reverting this to the previous example?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed @domenic, far prefer the original example as this new one doesn't make sense. the original example is something i can point to many instances of in microsoft products. i'm confused by the original comment, indicating that Firefox did not autofocus readonly controls. testing today, focus goes to the readonly text field just fine (chrome and firefox), as i'd expect. So maybe Firefox has reversed course to match up with other implementations since october?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I tentatively reverted back to the previous example
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, fair enough. |
||
| attribute DOMString <span data-x="dom-dialog-returnValue">returnValue</span>; | ||
| [<span>CEReactions</span>] undefined <span data-x="dom-dialog-show">show</span>(); | ||
| [<span>CEReactions</span>] undefined <span data-x="dom-dialog-show">show</span>(optional boolean preventInitialFocus); | ||
josepharhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [<span>CEReactions</span>] undefined <span data-x="dom-dialog-showModal">showModal</span>(); | ||
josepharhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [<span>CEReactions</span>] undefined <span data-x="dom-dialog-close">close</span>(optional DOMString returnValue); | ||
| };</code></pre> | ||
|
|
@@ -59243,8 +59243,9 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> { | |
|
|
||
| <div w-nodev> | ||
josepharhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <p>When the <dfn method for="HTMLDialogElement"><code data-x="dom-dialog-show">show()</code></dfn> | ||
| method is invoked, the user agent must run the following steps:</p> | ||
| <p>When the <dfn method for="HTMLDialogElement"><code | ||
josepharhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| data-x="dom-dialog-show">show(preventInitialFocus)</code></dfn> method is invoked, the user agent | ||
| must run the following steps:</p> | ||
|
|
||
| <ol> | ||
| <li><p>If the element already has an <code data-x="attr-dialog-open">open</code> attribute, then | ||
|
|
@@ -59256,7 +59257,8 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> { | |
| <li><p>Set the <code>dialog</code> element's <span>previously focused element</span> 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> | ||
| <li><p>If <var>preventInitialFocus</var> flag is not present or is set to false, run the | ||
| <span>dialog focusing steps</span> for the <code>dialog</code> element.</p></li> | ||
josepharhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </ol> | ||
josepharhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <p>When the <dfn method for="HTMLDialogElement"><code | ||
|
|
@@ -76934,10 +76936,21 @@ END:VCARD</pre> | |
|
|
||
| <ol> | ||
josepharhar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <li> | ||
| <p>Let <var>focusable area</var> be <var>child</var>, if <var>child</var> is a | ||
| <span>focusable area</span>; otherwise let <var>focusable area</var> be the result of <span | ||
| data-x="get the focusable area">getting the focusable area</span> for <var>child</var> given | ||
| <var>focus trigger</var>.</p> | ||
| <p>Let <var>focusable area</var> be null.</p> | ||
|
|
||
| <ol> | ||
| <li><p>If <var>focus target</var> is a <code>dialog</code> element and <var>child</var> is | ||
| <span>sequentially focusable</span>, let <var>focusable area</var> be | ||
| <var>child</var>.</p></li> | ||
|
|
||
| <li><p>Otherwise, if <var>focus target</var> is not a <code>dialog</code> element and | ||
| <var>child</var> is a <span>focusable area</span>, let <var>focusable area</var> be | ||
| <var>child</var>.</p></li> | ||
|
|
||
| <li><p>Otherwise, let <var>focusable area</var> be the result of <span data-x="get the | ||
| focusable area">getting the focusable area</span> for <var>child</var> given <var>focus | ||
| trigger</var>.</p></li> | ||
| </ol> | ||
|
|
||
| <p class="note">This step can end up recursing, i.e., the <span>get the focusable area</span> | ||
| steps might return the <span>focus delegate</span> of <var>child</var>.</p> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.