-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Disable / customize scrolling behavior of Element.focus #834
Comments
Interesting. I am pretty sure this is not specced, but it probably should be! How interoperable is it? I assume this kind of scrolling only happens for .focus(), not for other methods of focusing like tabbing? I think this is an eminently reasonable proposal, and would be happy to work on a PR or review one from you, if Blink is interested in implementing and nobody else objects. |
Tabbing also scrolls, and as was pointed out in www-style, it would be nice if it was possible to control smooth scrolling for that using the The dictionary to use for |
This isn't urgent from the blink implementation side, our implementation of CSS OM smooth scroll is temporarily on hold, but we do hope to resume soon. |
"No scrolling" option is also necessary. There is such use case. |
What is the use case? |
Suppose that multiple-tabs like UI, and a scrollable tab has a focusable element. Let's call it "Tab-A".
We'd like to do this in DevTools console tab of Google Chrome. |
See also this use case for the no scroll behavior: It would be great, if this feature would be easily feature detectable (i.e.: without trying to focus a hidden element or similar). |
I just saw another scenario where disabling scrolling probably makes sense - when JS is focusing an element based on pointer hover (for TV use cases). |
Generally, the input device for the TV is the remote controller. when hovering the element, focus event triggers the scroll behavior. Can |
I suggest adding Such as:
Element.focus() currently triggers scrolling the element into view. The result is reasonable when focusing based on Demo shows no scrolling behavior when focusing by Similar discussion is in w3c/csswg-drafts#1388. |
This seems like a good solution to me. There are several Blink developers on this thread who seem interested; can we find other vendors interested in such an addition? |
@RByers can you comment on whether there is implementation interest in chromium for @jihyerish's proposal? @smaug---- can you comment on the same for Gecko? |
That sounds like a good idea to me - I'd support implementing. It's up to @dtapuska on our input team to decide what priority we'd give it. |
I've created 734166 to track the Chromium issue. We will work on figuring out what kind of priority to set to it. But it seems to make sense to me to do. |
Looks reasonable to me. |
Filed https://bugzilla.mozilla.org/show_bug.cgi?id=1374045 |
Thank you! @jihyerish would you be interested in working on a pull request for the standard? (Otherwise I can work on this, but not until August or so.) |
Yes, I'd like to upload a PR. Thank you! : ) |
It's not great to use "block" to refer to a viewport location and then use "start" and "end" to refer to the top / bottom of the viewport given "start" and "end" usually refers to an inline direction. It's not entirely clear what this means in a document in vertical writing mode, or more broadly any page that scrolls horizontally. In particular, it's possible for a document to have both horizontally and vertically scrollable. What does "start" of a viewport mean in such a page? |
I considered the block flow direction here. Then, if the @rniwa It's a good point. : ) |
@yi-gu just raised an interesting point - when you type into an already focused input box it runs the focus steps and causes it to scroll into view. Do we also need some way to customize/disable this focus-based scrolling? |
Does it means that an already focused input box calls scrollIntoView() even if it's already within the viewport and its position doesn't change? I tested for the input box and found out: |
@RByers
The suggestion referred "scrollIntoViewIfNeeded()" which is a non-standard feature. This API doesn't work if an element is already within the view. (As far as I know, it is still supported in Webkit.) I think the use case that you mentioned above also could be supported by focus(), if scrollIntoView() can handle the condition when the element is already within the view, and ScrollIntoViewOptions is added to focus() as a parameter. [1] https://lists.w3.org/Archives/Public/www-style/2012May/0808.html, |
Addresses the most basic part of #834, allowing further customizations to be done by JavaScript code.
Hmm, I didn't mean to close this completely. Let me reopen. @zcorpan summarized the route we ended up taking in #2787 in w3c/csswg-drafts#1805 (comment) . Roughly, we now have Before adding more developer-facing abilities to
So: progress! But still worth keeping this bug open. |
Addresses the most basic part of whatwg#834, allowing further customizations to be done by JavaScript code.
I just spent a bunch of time trying to figure out why my scroll function was not working. It turns out, that is due to the scroll behavior of element.focus() |
Is there a way to get the same "no scroll" behavior when using the tab key? The current browser behavior is not sufficient because it doesn't detect if the element which is focused is behind another element. Therefore I want to disable it and implement my own version. I do NOT want to reimplement tabbing through focusable elements |
From www-style discussion: when
Element.focus()
is used the UA may scroll the element into view (it's not immediately obvious to me if this is specified or not). In that case, there's currently no way to request the scrolling to be smooth. Perhapsfocus
should take an optional ScrollBehavior like Element.scrollIntoView now does?The text was updated successfully, but these errors were encountered: