/// <summary>
        /// Handles the visibility styles and JS interop states.
        /// </summary>
        /// <param name="visible">True if component is visible.</param>
        protected virtual void HandleVisibilityStyles(bool visible)
        {
            if (visible)
            {
                jsRegistered = true;

                ExecuteAfterRender(async() =>
                {
                    await JSRunner.RegisterClosableComponent(dotNetObjectRef, ElementRef);
                });
            }
            else
            {
                jsRegistered = false;

                ExecuteAfterRender(async() =>
                {
                    await JSRunner.UnregisterClosableComponent(this);
                });
            }

            DirtyClasses();
            DirtyStyles();
        }