Skip to content

ScrollBehavior definition is missing 'instant' for scrollTo #46654

Closed
@patik

Description

@patik

Bug Report

πŸ”Ž Search Terms

instant
scrollbehavior
scrollTo
type definition

πŸ•— Version & Regression Information

v4.4.4, but it's also mentioned in #28755 (v3.2.1)

  • This is a crash

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

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 element.scrollTo() according to https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo as well as testing it in a browser

πŸ™‚ Expected behavior

The value of 'instant' is allowed when using element.scrollTo() according to https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo as well as testing it in a browser. Note that a similar issue, #28755, was about scrollIntoView(), which indeed does not allow 'instant'.

Activity

PaperStrike

PaperStrike commented on Nov 3, 2021

@PaperStrike

I guess it's microsoft/TypeScript-DOM-lib-generator@fe01c9a#r31507840, instant isn't valid anywhere ever since.
You may need to info MDN folks to update the docs. πŸ‘€

patik

patik commented on Nov 3, 2021

@patik
Author

I stand corrected! For anyone else who comes across this, in my testing I found that browsers do indeed treat instant the same as auto, so it's safe to simply drop the property unless you need smooth.

ObjectAssign

ObjectAssign commented on Sep 17, 2022

@ObjectAssign

@patik auto to me works as scrolling does, I guess that is because I have enabled smooth scroll in my browser...

However, I would really like the instant to be available

jiri-thiemel-te

jiri-thiemel-te commented on May 30, 2024

@jiri-thiemel-te

I stand corrected! For anyone else who comes across this, in my testing I found that browsers do indeed treat instant the same as auto, so it's safe to simply drop the property unless you need smooth.

That most definitely is not true. It depends on the CSS property scroll-behaviour value . The instant value needs to be allowed for behavior property of scrollTo and scrollIntoView.

The default value is auto. That one you can omit as developer. Not this one. When the scroll-behaviour is set to smooth and you want to scroll to an element without the animation then you need to pass behavior: instant. See https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo#behavior

helloint

helloint commented on Sep 26, 2024

@helloint

I stand corrected! For anyone else who comes across this, in my testing I found that browsers do indeed treat instant the same as auto, so it's safe to simply drop the property unless you need smooth.

not ideally solution but this works for me when upgrading typescript might not be an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @patik@helloint@PaperStrike@ObjectAssign@jiri-thiemel-te

        Issue actions

          ScrollBehavior definition is missing 'instant' for scrollTo Β· Issue #46654 Β· microsoft/TypeScript