Skip to content

Conversation

@josepharhar
Copy link
Contributor

@josepharhar josepharhar commented Aug 16, 2022

This implements the changes proposed here:
https://github.com/whatwg/html/wiki/dialog--initial-focus,-a-proposal#dialog-draft-text

Specifically:

  1. Make the dialog focusing steps look at sequentially focusable elements instead of any focusable element.
  2. Make the dialog element itself get focus if it has the autofocus attribute set.
  3. Make the dialog element itself get focus as a fallback instead of focus being "reset" to the body element.

There are additional open issues around dialog initial focus listed here:
#4184 (comment)

(See WHATWG Working Mode: Changes for more details.)


/interaction.html ( diff )
/interactive-elements.html ( diff )

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:
whatwg#4184 (comment)

TODO add a conformance requirement about autofocus:
whatwg#7709

TODO consider adding a <p class=XXX> for tab trapping:
whatwg#7707
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josepharhar
Copy link
Contributor Author

A big part of the proposal was writing up https://github.com/whatwg/html/wiki/dialog--initial-focus,-a-proposal#improving-conformance-requirements-and-examples as spec text, to replace the current single sentence "The dialog element represents a part of an application that a user interacts with to perform a task, for example a dialog box, inspector, or window."

Ah thanks, I totally missed this. It is now in the PR

@josepharhar
Copy link
Contributor Author

This does not implement the change where calling showModal() on <dialog autofocus> will cause the dialog itself to get focus. Probably the best way to spec that is to change the showModal() spec to check for the autofocus attribute and, if present, focus the dialog instead of going into the focus delegate steps.

I added a commit to do this. Instead of doing it all in showModal I changed the dialog focusing steps because I figured that it would still be important to run the other autofocus related steps at the end of the dialog focusing steps

application, or manually closed by the user.</p>

<p>Especially for modal dialogs, which are a familiar pattern across all types of applications,
authors should work to ensure that dialogs in their web applications behave in a way that is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended to be non-normative? If so, don't use "should".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended this to be normative when I wrote it. Do you think it's a bad normative requirement, e.g. because it's too vague? I'm not sure on the precedent there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Yes, I think it's not a good requirement because it's vague and not testable. Further, the wording "authors should work to ensure" makes the requirement about the work the author does, which is a bit off.

If it's not testable, I think making it non-normative is better. e.g. s/should work/are encouraged/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any remaining normative text in the section we're talking about, so I think this is resolved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph is still there and still says "authors should work to ensure".
Perhaps we could just change it to "authors are encouraged"?

application, or manually closed by the user.</p>

<p>Especially for modal dialogs, which are a familiar pattern across all types of applications,
authors should work to ensure that dialogs in their web applications behave in a way that is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended this to be normative when I wrote it. Do you think it's a bad normative requirement, e.g. because it's too vague? I'm not sure on the precedent there.

@josepharhar
Copy link
Contributor Author

Thanks for the review @domenic! I believe I've addressed all your comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agenda+ To be discussed at a triage meeting document conformance impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation normative change topic: dialog The <dialog> element topic: focus

Development

Successfully merging this pull request may close these issues.

6 participants