Open Closed

How to force scroll page to top on every pages #4351


User avatar
0
lan.dang created
  • ABP Framework version: v7.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:" When open new page, system still keep previous position. I want to it reset page to top, how can I do that?

14 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can try to call the javascript function to scroll to the top on LocationChanged event.

    https://blazor-university.com/routing/detecting-navigation-events/ https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.navigationmanager.locationchanged?view=aspnetcore-7.0

  • User Avatar
    0
    lan.dang created

    Thank you, What is component or page I should overwrite to add this script? I dont know which component will be called when any page loaded

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can try to add a Layout-Hooks

    https://docs.abp.io/en/abp/latest/UI/Blazor/Layout-Hooks

  • User Avatar
    0
    lan.dang created

    I tried this one before but got error "

    Do you know what is issue?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    What's your code?

  • User Avatar
    0
    lan.dang created

    I added new razor page

    Add to ConfigureServices

    Code behind is same as document

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Try to rename your class as ScrollToTopComponent

  • User Avatar
    0
    lan.dang created

    Hi, it is same error, I just change name to exact name AnnouncementComponent but not work as well

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I will test this.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share your project? liming.ma@volosoft.com

  • User Avatar
    0
    lan.dang created

    Yes i just add component and add it to ConfigureServices Please have a look at my change

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi This is an app issue, we will fix the scroll issue in the next patch release.

  • User Avatar
    0
    lan.dang created

    Thank you, waiting for hearing update from you

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    We will solve the problem as soon as possible

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11