Server-side Blazor 0.5.1 doesn't update active class on NavLink element
I have just published "default" server side application to Azure. I have made only one change in WeatherForecastService.cs
return Task.FromResult(Enumerable.Range(1, 500).Select(index => new WeatherForecast
As you can see service now returns 500 instead of 5 forecasts.
We can click on Home and Counter menu links and everything works as expected. Try to click on Fetch data. At first everything works, but active class on NavLink (strictly speaking on <a> element) is not removed from Home or Counter and not added to Fetch data.
http://blazorserwer.azurewebsites.net/
@Andrzej-W I think you are seeing the same issue that I referenced in aspnet/Blazor#1211; I was OK with adding the JS required by Bootstrap to my project but apparently some of the Bootstrap components will interfere with Blazor.
The suggest route was to consider BlazorStrap.
I am trying to port BlazorStrap from 0.3.0 to 0.5.1 and am having a couple of issues. When I resolve them I'll put out a PR for BlazorStrap.
@MarkStega it is not related to aspnet/Blazor#1211 at all. This is standard project created by VS. It doesn't require any JavaScript.
Problem is visible when I try to return 500 forecasts. When I return 5 or 50 forecasts it works correctly. Probably there is subtle bug somewhere in async code on the server or on the client.
Seeing this as well... It's not limited to just the navlink. Other simple bindings can fail to update as well, and it's fairly easy to reproduce.
Seems to be some kind of timing issue or race condition.
The problem goes away if you add any kind of delay to the back end:
public async Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
{
await Task.Delay(1); // this line fixes the issue
var rng = new Random();
return Enumerable.Range(1, 500).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
}).ToArray();
}
Removing the delay causes the problem to re-appear.
This problem still exists in 0.6.0
Any Error message in the console?
@vertonghenb I don't see any errors in web browser console.
@Andrzej-W, did you try to place the NavLink for FetchData between the NavLink for Home and that of the Counter, and see if the issue remains ?