Skip to content

Router scrolling does not work properly when dealing with content that is not immediately visible聽#30139

Description

@mackelito

馃殌 feature request

Relevant Package

This feature request is for @angular/router

Description

When using routerLink fragment to scroll to an anchor it might not work properly if unless the element is already loaded (this might be the case for a component that is rendered once data from a API has been loaded)

Another problem is that the anchor might be pushed down in the viewport when data is loaded.
A simple example: https://angular-7fpprl.stackblitz.io/qwe#qwe

Describe the solution you'd like

Perhaps there should be some wait mechanism in place that waits for the element to be rendered? I assume it would also need have a configurable timeout setting.

Also if the anchor is pushed down by dynamic content then perhaps position should be updated?

Describe alternatives you've considered

One option might be to create a custom directive that checks if the element exsists and then scrollIntoView() but it feels like monkey patching a feature that should be handled by the router

Activity

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions