You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ScrollBehavior definition is missing 'instant' for window.scrollTo #47441
window.scrollTo({top: 0,left: 0,behavior: 'instant'// This should be allowed})
?? Actual behavior
The value of instant cannot be assigned to behavior when using window.scrollTo.
?? Expected behavior
The value of instant is allowed when using window.scrollTo according to https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo as well as in real-world testing in major browsers. I just tested window.scrollTo with instant on Chrome, Firefox, and macOS Safari and it does not give the same behavior as auto. In my tests, auto produced smooth scrolling and instant scrolled instantly.
Please note that the MDN documentation specifies different behavior options for element.scrollTo and element.scrollIntoView vs. window.scrollTo. This bug report is specific to window.scrollTo. The existing ScrollBehavior type definition will most likely need to be bifurcated to handle all functions correctly.
Until the type definition is fixed, you can get the instant scrolling behavior by casting as any:
Please note that this issue is very similar to #46654, but that issue was related to element.scrollTo and this issue is related to window.scrollTo. The two functions have different options for ScrollBehavior. (And thanks to Craig Patik (@patik) - his work on #46654 saved me time in creating this issue!)
Just encountered this issue. Would be great to have this as MDN docs seem to suggest it is an option, and I only get the behaviour I need with instant and not auto which seems to fall back on the CSS style rule if set (I have it set to smooth). Have used 'instant' as ScrollBehavior in the meantime. Cheers.
Reacted by Jack Hermanson, OOPS! Studio! and CometstarMH
Activity
RandScullard commentedon Jan 14, 2022
Please note that this issue is very similar to #46654, but that issue was related to
element.scrollToand this issue is related towindow.scrollTo. The two functions have different options for ScrollBehavior. (And thanks to Craig Patik (@patik) - his work on #46654 saved me time in creating this issue!)BayanBennett commentedon Apr 27, 2022
Note that
behavior: "auto"inherits the behavior from the CSS scroll-behavior, which is why having the "instant" value is importantBayanBennett commentedon Apr 27, 2022
Seems like there's another task for this:
BayanBennett commentedon Apr 27, 2022
More context: It seems like the "instant" value isn't part of the CSSOM spec https://github.com/w3c/csswg-drafts/blob/main/cssom-view-1/Overview.bs#L407
EDIT:
instantis back due to w3c/csswg-drafts#8107, thanks to #47441 (comment) for pointing this out.zhangenming commentedon Feb 28, 2023
auto and instant behave differently in my browser
YahangWu commentedon Mar 29, 2023
This has been restored in cssom w3c/csswg-drafts#8107, please added it back. Thanks :))
curtisburns commentedon Mar 31, 2023
Just encountered this issue. Would be great to have this as MDN docs seem to suggest it is an option, and I only get the behaviour I need with
instantand notautowhich seems to fall back on the CSS style rule if set (I have it set tosmooth). Have used'instant' as ScrollBehaviorin the meantime. Cheers.Teamop commentedon Apr 19, 2023
it's already fixed in #53133 which was just include in v5.1-beta
cbroomemktw commentedon Apr 20, 2023
Terry (@Teamop) thanks! For anyone who can't update while still in beta you can brute force this setting as a workaround:
DanielRuf commentedon Jun 19, 2023
Exactly.
jakebailey commentedon Jul 9, 2023
As noted in #47441 (comment), this is already fixed and now released in TS 5.1.
helloint commentedon Sep 27, 2024
Can this small issue being published to latest 4.x? Upgrading to 5.x is a big change to the project and the entire eco