I have a Component with page attribute that matches parameters for selected parent and child category in a delivery platform.
@page "/{Alias}/speisekarte"
@page "/{Alias}/speisekarte/{CategoryText}"
@page "/{Alias}/speisekarte/{CategoryText}/{SubCategoryText}"
Here we have a sample the parent category "Pizza" and the child category "MyPizza":
https://v7pizzaboy.gastroblitz.de/duesseldorf-derendorf/speisekarte/pizza/mypizza
Problem is now that when changing the category via click it always jumps to the very beginning when switching to new Url of the SAME Component "MenuPage.razor".
<div class="swiper-slide swiper-slide-active" style="width: 136.25px;"
@onclick="(() => GotoCategory(category.Permlink))">
<a class="@(category == CurrentParentCategory ? "active" : "")" href="#" @onclick:preventDefault>
<img src="/img/@category.NavigationIcon" height="36" alt="Aktion" class="">
<span>@category.Name</span>
</a>
</div>
No matter if I use a href with destination link or NavigationManager:
public void GotoCategory(string permLink)
{
var url = $"/{My.Store.PrimaryAlias}/speisekarte/{permLink}";
NavigationManager.NavigateTo(url);
}
you can try yourself on page (link above):
- scroll down
- then click navigation link
Question is how can I change the given data plus the url but stay at the same scroll position for good user experience?