Skip to content

Commit a15a059

Browse files
authored
[Menu] Fix dispose error
1 parent 585a83d commit a15a059

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Core/Components/Menu/FluentMenu.razor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,14 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
240240
}
241241
}
242242

243-
if (_jsModule is not null)
243+
if (_jsModule is not null && _anchoredRegionModule is not null)
244244
{
245245
await _jsModule.InvokeVoidAsync("initialize", Anchor, Id, Open, _anchoredRegionModule, _dotNetHelper);
246246
}
247247
}
248248
else
249249
{
250-
if (_jsModule is not null && _reinitializeEventListeners)
250+
if (_jsModule is not null && _anchoredRegionModule is not null && _reinitializeEventListeners)
251251
{
252252
// If the menu was closed, remove its set event listeners. If it opened (ie if the menu starts out closed),
253253
// we should set them now.
@@ -397,13 +397,13 @@ public async ValueTask DisposeAsync()
397397

398398
try
399399
{
400-
if(_jsModule is not null)
400+
if (_jsModule is not null)
401401
{
402402
await _jsModule.InvokeVoidAsync("dispose", Anchor);
403403
await _jsModule.DisposeAsync();
404404
}
405405

406-
if(_anchoredRegionModule is not null)
406+
if (_anchoredRegionModule is not null)
407407
{
408408
await _anchoredRegionModule.DisposeAsync();
409409
}

0 commit comments

Comments
 (0)