arivera12 / BlazorHistory

HTML5 History API Implementation for Blazor without any JavaScript.
MIT License
12 stars 1 forks source link

Use BlazorHistory in Blazor Server (server-side) #3

Open Bilchenko opened 2 years ago

Bilchenko commented 2 years ago

Hi,

I've tested your BlazorHistory package in Blazor WebAssembly (client-side) VS 2022 .Net Core 6.0 Scroll position is restored on back action.

Unfraternally, BlazorHistory package in Blazor Server (server-side) is not work (VS 2022 .Net Core 6.0). Scroll position is not restored.

Is BlazorHistory designed only for Blazor WebAssembly (client-side)?

arivera12 commented 2 years ago

BlazorHistory should work with both blazor server and web assembly. But I don't remember testing it in blazor server. I would need to do some tests on my local to see what's happening. Can you share your steps to reproduce this issue?

arivera12 commented 2 years ago

What I think it could be happening its that blazor server history.scrollRestoration it's not being preserved or is not in auto on blazor server.

Bilchenko commented 2 years ago

Create new project Blazor Server. NuGet: BlazorHistory 1.0.0 Modify Program.cs builder.Services.AddBlazorHistoryService(); Modify Index.razor: @for (var i = 0; i <= 100; i++) { <p>test line</p> } <a href="Counter">Go to Counter</a>

Bilchenko commented 2 years ago

I have used from your demo: async() => await BlazorHistoryService.ScrollRestoration(ScrollRestorationType.Auto) async() => await BlazorHistoryService.ScrollRestoration(ScrollRestorationType.Manual) await BlazorHistoryService.ScrollRestoration()

scrollRestoration lokks like changed, but index page still opening from top on back action.