Unplanned
Last Updated: 07 Jul 2022 08:43 by Brian
Brian
Created on: 07 Jul 2022 08:43
Category: AnimationContainer
Type: Bug Report
2
Exception if AnimationContainer hides after page navigation

I use an AnimationContainer to create a notification popup. It animates on the way in, pauses for a few seconds, and then animates back out. If I navigate to another page during the delay, it looks like .HideAsync() still gets called and it causes an error.

Error: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'DotNetObjectReference`1'.

Here is a test page. The yellow code causes the issue. The green code is the workaround.

@implements IDisposable

<TelerikButton OnClick="@ToggleContainer">Toggle Animation Container</TelerikButton>

<NavLink href="/">Go to Home page</NavLink>

<TelerikAnimationContainer @ref="AnimContainer" Top="50px" Left="50px" Width="250px" Height="150px"
                           AnimationType="AnimationType.ZoomOut" Class="k-popup">
    AnimationContainer
</TelerikAnimationContainer>

@code {
    TelerikAnimationContainer AnimContainer { get; set; }

    async Task ToggleContainer()
    {
        await AnimContainer.ShowAsync();

        await Task.Delay(3000);

        //if (AnimContainer != null)
        //{
            await AnimContainer.HideAsync();
        //}
    }

    void IDisposable.Dispose()
    {
        AnimContainer = null;
    }
}

0 comments