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

Proposal: Add the option to define the scroll behavior of focus() #2712

Closed
jihyerish opened this issue May 29, 2017 · 3 comments
Closed

Proposal: Add the option to define the scroll behavior of focus() #2712

jihyerish opened this issue May 29, 2017 · 3 comments

Comments

@jihyerish
Copy link
Contributor

Could Element.focus() have the scrollOption to define the scroll behavior?

Such as:

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().

Element.focus() currently triggers scrolling 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.

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 and for other use cases.
Customizing the scrolling behavior of Element.focus already been discussed in #834.
Also, similar discussion is in w3c/csswg-drafts#1388.

@domenic
Copy link
Member

domenic commented May 29, 2017

I'm a little confused; isn't this a dupe of #834?

@jihyerish
Copy link
Contributor Author

Yes, this is a continuous discussion of #834, but I'm suggesting the solution of it.
Would this be right to be discussed in #834?

@domenic
Copy link
Member

domenic commented May 30, 2017

Yes, it's better to keep the discussion in one place :). Let's move it there.

@domenic domenic closed this as completed May 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants