Skip to content

PopoverService: do not call JS during OnInitializedAsync#7441

Merged
ScarletKuro merged 2 commits intoMudBlazor:devfrom
ScarletKuro:popover_fix
Aug 29, 2023
Merged

PopoverService: do not call JS during OnInitializedAsync#7441
ScarletKuro merged 2 commits intoMudBlazor:devfrom
ScarletKuro:popover_fix

Conversation

@ScarletKuro
Copy link
Member

@ScarletKuro ScarletKuro commented Aug 29, 2023

Description

I recently spoke with someone experiencing issues with BSS when deployed in a cloud environment. It appears that all components related to popovers exhibit a slight delay during the initial load, which subsequently disappears.

With this #7333, we understand that it's important not to execute any JavaScript during the OnInitializedAsync lifecycle method. The method CreatePopoverAsync is invoked during OnInitializedAsync, and within it, there's a call to InitializeServiceIfNeededAsync, which itself triggers a JavaScript call and employs a locking mechanism. This is likely the root cause of the delay.

In the previous implementation of PopoverService there were no JavaScript+locking on the OnInitializedAsync phase. My initial intention was to initialize the service as early as possible, but the removal of InitializeServiceIfNeededAsync from CreatePopoverAsync doesn't impact functionality. The InitializeServiceIfNeededAsync is invoked later in the OnAfterRenderAsync lifecycle anyway, where it should be called.

How Has This Been Tested?

I sadly cannot really test if this fixes the delay, as it's hard to replicate the environment where it happens.
However, even if my identification of the root cause of the delay is incorrect, the proposed change is still a valid improvement as this logic doesn't work in prerendering.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels Aug 29, 2023
@ScarletKuro ScarletKuro merged commit 29e7efb into MudBlazor:dev Aug 29, 2023
@ScarletKuro ScarletKuro deleted the popover_fix branch August 29, 2023 16:03
ilovepilav pushed a commit to ilovepilav/MudBlazor that referenced this pull request Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant