Skip to content

Commit b6ee0f1

Browse files
committed
Menu should be closed on location change
1 parent ed037ca commit b6ee0f1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Radzen.Blazor/RadzenMenu.razor.cs

+19
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,24 @@ public void AddItem(RadzenMenuItem item)
225225
/// </summary>
226226
[Parameter]
227227
public string ToggleAriaLabel { get; set; } = "Toggle";
228+
229+
/// <inheritdoc />
230+
protected override void OnInitialized()
231+
{
232+
NavigationManager.LocationChanged += OnLocationChanged;
233+
}
234+
235+
private void OnLocationChanged(object sender, Microsoft.AspNetCore.Components.Routing.LocationChangedEventArgs e)
236+
{
237+
IsOpen = !IsOpen;
238+
StateHasChanged();
239+
}
240+
241+
/// <inheritdoc />
242+
public override void Dispose()
243+
{
244+
base.Dispose();
245+
NavigationManager.LocationChanged -= OnLocationChanged;
246+
}
228247
}
229248
}

0 commit comments

Comments
 (0)