Skip to content
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

Consider conformance guidance for authors to explicitly declare autofocus for dialog element #7709

Closed
scottaohara opened this issue Mar 15, 2022 · 5 comments
Labels
document conformance impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation topic: dialog The <dialog> element.

Comments

@scottaohara
Copy link
Collaborator

scottaohara commented Mar 15, 2022

Per the dialog initial focus proposal, this unresolved comment has been moved here for further discussion:

As such, authors should use the autofocus attribute on the descendant element of the dialog that the user will expect to immediately interact with after the dialog opens. If there is no such element, then authors should use the autofocus attribute on the dialog element itself.

Summary of exchange between Domenic and Aaron:

  • This would mean conformance checkers will warn authors if a dialog element doesn't have autofocus specified somewhere in the dialog.
  • agreement that this is probably the right thing to do, but worry about potential warning fatigue or requiring redundant autofocus attributes.

cc @sideshowbarker for thoughts on the matter

@annevk annevk added the topic: dialog The <dialog> element. label Mar 16, 2022
@zcorpan zcorpan added document conformance impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation labels Mar 31, 2022
@zcorpan
Copy link
Member

zcorpan commented Mar 31, 2022

This seems like a good thing to require if we think that making web developers think about and make a decision about which element should have autofocus results in a net better UX compared to the default behavior when there's no autofocus.

I'm not so worried about warning fatigue in this case, as long as the message in the conformance checker is understandable and explains the motivation for needing the autofocus attribute.

There's some precedence: the sizes attribute was optional at first and had a default value (100vw). We noticed that many developers omitted the sizes attribute (since it was optional) but the default was not always appropriate. So we made it required, even when you want the default value, and developers who wanted the error to go away had to think about what value to use in sizes.

@domenic
Copy link
Member

domenic commented Aug 9, 2022

Regarding the question of which issues in #4184 (comment) should be considered blocking for writing up a spec of https://github.com/whatwg/html/wiki/dialog--initial-focus,-a-proposal#initial-dialog-focus-logic : This is about whether to include a single sentence in the spec proposal there. And we have at least some positive support for including the sentence, from @zcorpan and the two thumbs-uppers. So I think we should call this resolved, and that sentence should be included in the PR.

@josepharhar
Copy link
Contributor

So I think we should call this resolved, and that sentence should be included in the PR

Great! How do I make a conformance requirement/guidance? Is there an example I could copy?

josepharhar added a commit to josepharhar/html that referenced this issue 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. 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
@domenic
Copy link
Member

domenic commented Aug 19, 2022

You can learn more about authoring conformance requirements here: https://html.spec.whatwg.org/#conformance-requirements-for-authors . Searching for "Authors should" in the spec will turn up a few examples of the type we're talking about. For this requirement in particular, I think it's about just keeping the sentence mentioned in the OP, when rewriting the dialog element introduction section.

@josepharhar
Copy link
Contributor

I think it's about just keeping the sentence mentioned in the OP

That sentence is now in the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
document conformance impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation topic: dialog The <dialog> element.
Development

No branches or pull requests

5 participants