Skip to content

Define the block flow and inline base directions for dom-focus #9518

Description

@dlrobertson

When Element.focus() is used, the element should be scrolled into view such that the element is in a defined position. Currently dom-focus states:

[...] scroll the element into view with scroll behavior "auto", block flow direction position set to an implementation-defined value, and inline base direction position set to an implementation-defined value.

Added focus/focus-centers-element.html in web-platform-tests/wpt#41029 that essentially checks that Element.focus() behaves similar to Element.scrollIntoView({block: "center", inline: "center"}).

Test Blink WebKit Gecko Gecko (after bug 1842679)
Element.focus() center in the block direction
Element.focus() center in the inline direction
Element.focus() center in both directions

Since browsers seem to agree that Element.focus() should center the element, it might make sense to specify this instead of leaving this implementation defined. Several web-platform tests assume that Element.focus() will cause an element to end in a certain scroll position (e.g. css/css-scroll-snap/scroll-target-margin-005.html), but AFAIK this is essentially undefined behavior (at least from the specs point of view).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions