-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Focusing algorithm is missing a "scroll the element into view" step #94
Comments
Perhaps @rodneyrehm would like to take a stab at this himself? |
sure, if you tell me what I'm supposed to do :)
The Based on that I'd suggest to add "executing the scroll an element into view" as step 6 of the focus activation sequence, i.e. after the event received focus. While we're on the topic, I wonder if it is feasible to use the focus event to prevent the "scroll element into view" step from happening. The |
@rodneyrehm you basically want to patch "source" within this repository, but see README.md for more detailed instructions. You also want to use the HTML Standard as reference, not its W3C copy. I think your suggestion is correct though and would recommend you make a pull request. @Hixie and maybe @smaug---- would have to review it. |
So, this being The Web™, of course there's an extra complication. When the focused element is outside the viewport:
Testcase: http://jsfiddle.net/cvrebert/nwzfo2dr/ |
@cvrebert true, but shouldn't the scroll an element sequence cover that? |
@rodneyrehm Unless I'm missing something, https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view scrolls an element to either the top or the bottom of the viewport, depending on whether the "align to top" flag is set. So (a) specing the "scroll into center" behavior isn't as easy as simply delegating to a CSSOM View algorithm (at least until http://w3bug.com/17152 gets fixed) (b) specing the "scroll to near edge" behavior would seem to require the HTML spec to compute the "align to top" flag itself. But my main point was that specing either behavior means that two of the browsers will need to change their existing behavior. Are the vendors willing to do that? |
Additionally, in my testing, all the current major browsers only perform a scroll if the element isn't within the viewport (akin to the nonstandard |
I have to admit that I care less about the point the focused element is scrolled to and more about the missing feature to prevent that from happening at all. That said, I understand and agree with all raised concerns. Simply appending a reference to the scroll element into view algorithm to the focus activation sequence won't cut it. |
@zcorpan should probably weigh in here. When it comes to scrolling there's also something to be said to give user agents some leeway in how to handle things since it's a user interface matter. Perhaps the CSSOM algorithm needs to account for that. |
This is the same feature as in https://www.w3.org/Bugs/Public/show_bug.cgi?id=17152 AFAICT. I'm happy to provide hooks HTML needs here. |
@zcorpan So is anything blocking you on adding the hooks (aside from there not being enough hours in the day)? |
Nothing in particular, no. |
Hello! Not sure if here's the proper forum, but I just wanted to raise a concern about a potential exceptional case where the scrolling step should probably be skipped: when focus is restored to the previously-active element after a modal dialog is closed. This clause appears in the referenced document:
In cases where this element was not inside the viewport at the moment the dialog was first opened, executing the scrolling step will usually cause undesirable, disorienting scrolling. On the other hand, in most major browsers (at least in the ones I've tested), closing a dialog that was opened via For some more background on this issue with concrete use cases and demos, please see the corresponding jQuery UI ticket as an example of why I believe this case should be handled as an exception: I hope this is clear, and please don't hesitate to let me know if there's a better place to ask about this. Thanks! |
Those functions block script execution until the system dialogs are closed. The |
Thanks for the quick response! That's an excellent point and an absolutely valid argument about the technical behavior of those functions. I hadn't fully reasoned about why, exactly, their closing behavior seemed exceptional compared to most modal dialog widget implementations I've seen, including Chrome's implementation of the While the technical differences are now clearer, my counter-argument is that the perceived behavioral differences should probably still be reconciled so that the recommendation for what should happen when closing a modal dialog of any kind (including The primary use case family I can think of where dialog "close, focus, scroll" behavior would be most disruptive is any case where opening the dialog was triggered by an event listener attached to some ancestor of the (out-of-viewport) active element (e.g. shortcut keys, scroll listeners, etc.). Also dialogs triggered by something other than user input. Some open questions are:
Thoughts? Thanks again for your feedback! |
@zcorpan Any progress in adding the requisite cssom-view hooks? |
No :-( Sorry for delaying this. Will fix this week. |
@zcorpan Great! And what about either |
Has it been decided whether the scroll into view step should honor the scroll-behavior property? I just opened https://bugzilla.mozilla.org/show_bug.cgi?id=1257600 for Firefox on this - at the moment, focus scrolls are always instant in Firefox. |
It probably should, but that is not specified yet. See |
(This is an intentional duplicate of https://www.w3.org/Bugs/Public/show_bug.cgi?id=27913 since that bug is in the wrong WG and an obscure Bugzilla Component.)
Basically, https://html.spec.whatwg.org/multipage/interaction.html#focus-update-steps doesn't seem to mention anything about scrolling the focused element into view if it was outside the viewport, even though all browsers do this in practice (simple testcase) most of the time (there are apparently some exceptional cases). So a step (presumably invoking https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view) should be added to make the spec reflect reality. I haven't dug deep enough to suggest exactly where in that algorithm the new step should be inserted.
The text was updated successfully, but these errors were encountered: