I have been experiencing the following error in several parts of my code, particularly after the SECOND attempt to use a dropdown menu that opens a popup menu. Error message looks like this:
Uncaught Error Error: System.ArgumentException: There is no tracked object with id '3'. Perhaps the DotNetObjectReference instance was already disposed. (Parameter 'dotNetObjectId')
at endInvokeDotNetFromJS (https://localhost:44333/_framework/blazor.server.js:1:3700)
at <anonymous> (https://localhost:44333/_framework/blazor.server.js:1:72054)
at _invokeClientMethod (https://localhost:44333/_framework/blazor.server.js:1:72040)
at _processIncomingData (https://localhost:44333/_framework/blazor.server.js:1:70082)
at connection.onreceive (https://localhost:44333/_framework/blazor.server.js:1:64485)
at o.onmessage (https://localhost:44333/_framework/blazor.server.js:1:48819)
The following sample code reproduces the error when I do the following:
1) click on the dropdown to open the popup menu
2) move the mouse over the popup menu items to make sure the color changes (hover)
3) click on a menu item
4) click away somewhere else on the screen---Error occurs
Sample code (Blazor Server, DotNet 6.0):
<SfDropDownButton >
<ChildContent>
<DropDownButtonEvents Opened="OnOpen"></DropDownButtonEvents>
</ChildContent>
<PopupContent>
<SfMenu TValue="DataModel" Items="@menuItems" @ref="@MenuObj" />
</PopupContent>
</SfDropDownButton>
@code
{
SfMenu<DataModel>? MenuObj;
private List<DataModel> menuItems = new()
{
new DataModel { Id = "parent1", Text = "Appliances"},
new DataModel { Id = "parent2", Text = "Accessories"},
};
private class DataModel
{
public string? Text { get; set; }
public string? Id { get; set; }
public string? ParentId { get; set; }
}
public async Task OnOpen()
{
await MenuObj.Open();
}
}
Hi Dave,
We have validated your reported query and based on dropdown button behavior, when we click the item within the dropdown popup or when we click outside, it should be close. But in your sample code, you did not handle for closing dropdown popup for selecting the menu item. Please refer the below code snippet to overcome your reported issue.
<SfDropDownButton @ref="dropDownBtnObj"> <PopupContent> <SfMenu TValue="DataModel" Items="@menuItems" @ref="@MenuObj"> <MenuFieldSettings ItemId="Id" Text="Text" ParentId="ParentId"></MenuFieldSettings> <MenuEvents TValue="DataModel" ItemSelected="OnSelect"></MenuEvents> </SfMenu> </PopupContent> </SfDropDownButton>
@code { ……………..
private void OnSelect() { dropDownBtnObj.Toggle(); } } |
Could you please check the above code and get back to us, if you need any further assistance on this.
Note: In menu component, Open method only for using to open the hamburger mode menu. Not for default menu.
Regards,
YuvanShankar A
Thank you for the correction. It works OK now.
Hi Dave,
We are happy to hear that your requirement has been fulfilled. Please get back to us if you need any further assistance on this.
Regards,
YuvanShankar A