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

NavigationManager different behavior on WebAssembly since 8.0.3 #55171

Closed
1 task done
alex-fitplans opened this issue Apr 16, 2024 · 3 comments
Closed
1 task done

NavigationManager different behavior on WebAssembly since 8.0.3 #55171

alex-fitplans opened this issue Apr 16, 2024 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components investigate Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue Status: No Recent Activity

Comments

@alex-fitplans
Copy link

alex-fitplans commented Apr 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm not exactly sure how to title this issue.

Consider the following simplified code, that adds a dummy navigation before displaying a popup (here using mudblazor, but the issue isn't specific to it), so that the user can navigate back to close it:

@page "/"
@inject NavigationManager NavigationManager
@inject IDialogService DialogService
@using MudBlazor
@implements IDisposable
@rendermode InteractiveServer

<PageTitle>Home</PageTitle>

<MudButton OnClick="Callback" Variant="Variant.Filled" Color="Color.Primary">Click Me</MudButton>

@code
{
    private IDialogReference? _currentDialog = null;
    
    protected override void OnInitialized()
    {
        base.OnInitialized();
        NavigationManager.LocationChanged += NavigationManagerOnLocationChanged; 
    }

    private void NavigationManagerOnLocationChanged(object? sender, LocationChangedEventArgs e)
    {
        if (_currentDialog != null)
            _currentDialog.Close();
    }

    private async void Callback()
    {
        var options = new DialogOptions { CloseOnEscapeKey = true };
        NavigationManager.NavigateTo("/#", false, false);
        _currentDialog = await DialogService.ShowAsync<SampleDialog>("Simple Dialog", options);
        var result = await _currentDialog.Result; 
        if (!result.Canceled)
        {
            // Do something
        }
        
        // Navigate back - example
        NavigationManager.NavigateTo("/", false, true);
    }

    public void Dispose()
    {
        NavigationManager.LocationChanged -= NavigationManagerOnLocationChanged; 
    }
}

This code worked fine both on WebAssembly and InteractiveServer modes until 8.0.2. After 8.0.3, the same code still works in InteractiveServer, but no longer pops the popup in WebAssembly.

Expected Behavior

I would expect the same behavior between WebAssembly and Interactive Server modes.

Steps To Reproduce

I've created a small repro here: https://github.com/alex-fitplans/sample-popup
Simply click on the button on the home page.

Downgrade to 8.0.2 (or to previous commit) to restore the functionality.

Exceptions (if any)

No response

.NET Version

8.0.3

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Apr 16, 2024
@mkArtakMSFT mkArtakMSFT added this to the 8.0.x milestone Apr 17, 2024
@mkArtakMSFT mkArtakMSFT added the Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue label Apr 17, 2024
Copy link
Contributor

Thank you for filing this issue. In order for us to investigate this issue, please provide a minimal repro project that illustrates the problem without unnecessary code. Please share with us in a public GitHub repo because we cannot open ZIP attachments, and don't include any confidential content.

@dotnet-policy-service dotnet-policy-service bot added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Apr 17, 2024
@mkArtakMSFT
Copy link
Member

@alex-fitplans please make sure you provide a repro without any dependencies (MudBlazor in this case).

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components investigate Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue Status: No Recent Activity
Projects
None yet
Development

No branches or pull requests

2 participants