Skip to content

[css-overflow][cssom-view] Set the option for scrolling behavior triggered by focus #1388

@jihyerish

Description

@jihyerish

Element.focus() is used the UA may scroll the element into view. The result is reasonable when focusing based on onkeydown. But when focusing by mouseover the element, focus event also triggers the scroll behavior.

The input device of the smart TV is the remote controller. Focusing an element with the remote controller is based on pointing(mouseover) and pressing buttons(onkeydown).
Focusing by mouseover may bring too much scrolling. This behavior doesn't meet with the requirement of TV app developers and users and it isn't good UX for the smart TV.

Demo shows no scrolling behavior when focusing by mouseover. If the option isn't checked, it also shows the result of the default scroll behavior triggered by Element.focus().

It could be nice if we can disable the scrolling behavior when the focus is triggered by mouseover or for other use cases.
Customizing the scrolling behavior of Element.focus already been discussed in whatwg/html#834.

I think there could be some approaches for this:

  1. New Property - focus-scroll
    could customize the scrolling behavior when it's applied to the scrollable area.
Value: auto | none | smooth
  • auto: Element.focus() makes the element scroll into view
  • none: Element.focus() doesn't make the scrolling behavior
  • smooth: Element.focus() makes the element come into view with smooth scrolling

or

  1. Add scrollOptions as a parameter for Element.focus()
    could customize the scrolling behavior triggered by focus.
Element.focus(scrollOptions);

scrollOptions
{
  behavior: "auto" | "none" | "smooth",
  block: "start" | "end"
 }
  • auto: Element.focus() makes the element scroll into view
  • none: Element.focus() doesn't make the scrolling behavior
  • smooth: Element.focus() makes the element come into view with smooth scrolling

scrollOptions refers to the scrollIntoViewOptions of Element.scrollIntoView().

The naming of focus-scroll may not proper, and the second approach; adding scrollOptions would be more reasonable.
I'm think many developers need this feature.

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