Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-side Blazor 0.5.1 doesn't update active class on NavLink element #15751

Closed
Andrzej-W opened this issue Jul 28, 2018 · 7 comments
Closed
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@Andrzej-W
Copy link

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/

@MarkStega
Copy link

MarkStega commented Jul 30, 2018

@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.

@Andrzej-W
Copy link
Author

@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.

@srowan
Copy link

srowan commented Sep 22, 2018

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.

@Andrzej-W
Copy link
Author

This problem still exists in 0.6.0

@vertonghenb
Copy link
Contributor

Any Error message in the console?

@Andrzej-W
Copy link
Author

@vertonghenb I don't see any errors in web browser console.

@enetstudio
Copy link

@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 ?

SteveSandersonMS referenced this issue in SteveSandersonMS/BlazorMigration Nov 27, 2018
@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/blazor Oct 27, 2019
@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Oct 27, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

6 participants