Skip to content

[css-overflow-5] :focus and :focus-within styles with focused scroller pseudo-element #11361

@flackr

Description

@flackr

When the user has focused a ::scroll-button or ::scroll-marker, the returned document.activeElement is the scrolling container as the activeElement API expects an element and this is consistent with having an "inner navigable" on the scrolling container similar to a shadow tree or inner frame per https://html.spec.whatwg.org/multipage/interaction.html#dom-documentorshadowroot-activeelement-dev:

For the purposes of this API, when a child navigable is focused, its container is focused within its parent's active document. For example, if the user moves the focus to a text control in an iframe, the iframe is the element returned by the activeElement API in the iframe's node document.

Similarly, when the focused element is in a different node tree than documentOrShadowRoot, the element returned will be the host that's located in the same node tree as documentOrShadowRoot if documentOrShadowRoot is a shadow-including inclusive ancestor of the focused element, and null if not.

The question is when these pseudos are focused, which elements have :focus or :focus-within styles?

Since the pseudos themselves can be styled by :focus, I think the most natural would be that the scrolling container matches :focus-within but not :focus. This seems the most natural, but is inconsistent with iframes and shadow dom (see demo):

  • When an element in a subframe is focused, it seems to not apply focus or focus-within to the frame container
  • shadow dom applies :focus to the host element and :focus-within to it and its ancestors.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions