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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElementInternals: Add a capability to set the default focus behavior #5120

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tkent-google
Copy link
Collaborator

@tkent-google tkent-google commented Dec 3, 2019

This commit introduces 'focusBehavior' IDL attribute of ElementInternals
interface. It accepts "unfocusable", "focusable", and "simple-control",
and affects focus behavior of ElementInternals' target element.

This fixes WICG/webcomponents#762


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


馃挜 Error: Wattsi server error 馃挜

PR Preview failed to build. (Last tried on Jan 15, 2021, 7:59 AM UTC).

More

PR Preview relies on a number of web services to run. There seems to be an issue with the following one:

馃毃 Wattsi Server - Wattsi Server is the web service used to build the WHATWG HTML spec.

馃敆 Related URL

Parsing MDN data...
Parsing...



If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please file an issue.

This commit introduces 'focusBehavior' IDL attribute of ElementInternals
interface.  It accepts "unfocusable", "focusable", and "simple-control",
and affects focus behavior of ElementInternals' target element.

This fixes WICG/webcomponents#762
@annevk
Copy link
Member

annevk commented Dec 3, 2019

@alice raises an interesting question at WICG/webcomponents#762 (comment) which I also mentioned at #4607 (comment). How does :focus-visible fit into all this?

@annevk annevk added addition/proposal New features or enhancements topic: focus labels Dec 3, 2019
@tkent-google tkent-google changed the title ElementInternals: Add a capability to set the default focus bahvior ElementInternals: Add a capability to set the default focus behavior Dec 9, 2019
@tkent-google
Copy link
Collaborator Author

@domenic @annevk Do you have any comments on this PR?

@domenic
Copy link
Member

domenic commented Dec 18, 2019

I pushed some editorial tweaks.

The one thing I wonder is whether the normative impacts of an autonomous custom element's focus behavior should show up elsewhere in the spec. Maybe the bulleted list "Elements that meet all the following criteria" in https://html.spec.whatwg.org/#focusable-area ? And we might want to add a sentence near https://html.spec.whatwg.org/#click-focusable, perhaps after the two bullet points saying something like

For focusable areas that are autonomous custom elements, user agents should consider the element's focus behavior in determining whether the element is click focusable or sequentially focusable.

But, maybe this is all redundant with the sentence you added in https://html.spec.whatwg.org/#tabindex-value. In general the "If the value is null" section there is kind of confusing when compared with the "Elements that meet all the following criteria" in https://html.spec.whatwg.org/#focusable-area, hmm.

Thoughts welcome. (Perhaps from @rakina to as our focus spec expert.)

@domenic domenic added the topic: custom elements Relates to custom elements (as defined in DOM and HTML) label Dec 18, 2019
@rakina
Copy link
Member

rakina commented Dec 19, 2019

The one thing I wonder is whether the normative impacts of an autonomous custom element's focus behavior should show up elsewhere in the spec. Maybe the bulleted list "Elements that meet all the following criteria" in https://html.spec.whatwg.org/#focusable-area ? And we might want to add a sentence near https://html.spec.whatwg.org/#click-focusable, perhaps after the two bullet points saying something like

For focusable areas that are autonomous custom elements, user agents should consider the element's focus behavior in determining whether the element is click focusable or sequentially focusable.

But, maybe this is all redundant with the sentence you added in https://html.spec.whatwg.org/#tabindex-value. In general the "If the value is null" section there is kind of confusing when compared with the "Elements that meet all the following criteria" in https://html.spec.whatwg.org/#focusable-area, hmm.

I agree with adding another explanation for sequential & click focusability.
For the focusable area definition, I think we should add more after the "or the element is determined by the user agent to be focusable" to specifically call out the custom elements, or maybe specifically refer to the section in the tabindex value or even move it? (It was awkward for that section to be in the "tabindex value" part to begin with, should've moved it when the great focus spec rewrite happened :D)

- Add a paragraph next to the click focusable definition
@tkent-google
Copy link
Collaborator Author

Thank you for the comments.
I think my initial change had minimum necessary changes. However it was not so helpful.

The one thing I wonder is whether the normative impacts of an autonomous custom element's focus behavior should show up elsewhere in the spec. Maybe the bulleted list "Elements that meet all the following criteria" in https://html.spec.whatwg.org/#focusable-area ? And we might want to add a sentence near https://html.spec.whatwg.org/#click-focusable, perhaps after the two bullet points saying something like

For focusable areas that are autonomous custom elements, user agents should consider the element's focus behavior in determining whether the element is click focusable or sequentially focusable.

That's a good idea. Done.

But, maybe this is all redundant with the sentence you added in https://html.spec.whatwg.org/#tabindex-value. In general the "If the value is null" section there is kind of confusing when compared with the "Elements that meet all the following criteria" in https://html.spec.whatwg.org/#focusable-area, hmm.

I agree with adding another explanation for sequential & click focusability.
For the focusable area definition, I think we should add more after the "or the element is determined by the user agent to be focusable" to specifically call out the custom elements, or maybe specifically refer to the section in the tabindex value or even move it? (It was awkward for that section to be in the "tabindex value" part to begin with, should've moved it when the great focus spec rewrite happened :D)

I added one sentence to the table in order to link to null tabindex value. What do you think?

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.

This looks great to me. /cc @whatwg/components to get broader input / multi-implementer interest.

Copy link
Member

@rakina rakina left a comment

Choose a reason for hiding this comment

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

lgtm

@tkent-google
Copy link
Collaborator Author

WPT PR: web-platform-tests/wpt#21063

same as general <span>focusable</span> elements such as <span data-x="editing host">editing
hosts</span>.</p></dd>

<dt>"<dfn><code data-x="ce-focusBehavior-simple-control">simple-control</code></dfn>"</dt>
Copy link
Member

Choose a reason for hiding this comment

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

Per https://whatwg.org/style-guide#tone I don't think we should use this name. Probably best discussed at WICG/webcomponents#762 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements topic: custom elements Relates to custom elements (as defined in DOM and HTML) topic: focus
Development

Successfully merging this pull request may close these issues.

Mechanism for setting the tabindex focus flag without sprouting tabindex attribute?
4 participants