Skip to content

MudPopover: Log instead of throw when no provider is in the render scope#13371

Merged
danielchalmers merged 4 commits into
MudBlazor:devfrom
danielchalmers:claude/youthful-montalcini-95e54b
Jun 28, 2026
Merged

MudPopover: Log instead of throw when no provider is in the render scope#13371
danielchalmers merged 4 commits into
MudBlazor:devfrom
danielchalmers:claude/youthful-montalcini-95e54b

Conversation

@danielchalmers

@danielchalmers danielchalmers commented Jun 26, 2026

Copy link
Copy Markdown
Member

When a popover-based component (MudDatePicker, MudDateRangePicker, MudSelect, MudMenu, ...) initializes but no MudPopoverProvider is subscribed in its render scope, PopoverService.CreatePopoverAsync threw an InvalidOperationException from the component's OnInitializedAsync.

In a Blazor Web App with per-page interactivity this is a common misconfiguration: the providers sit in the static MainLayout while the components run on an interactive page, so the circuit-scoped PopoverService has no subscribed provider. Throwing from a lifecycle method during the render batch tears down the circuit mid-render, and the sibling components' pending renders then fault with a cryptic ObjectDisposedException (ArrayBuilder.GrowBuffer -> RenderTreeDiffBuilder.InsertNewFrame -> Renderer.ProcessRenderQueue) — which is what users actually see, hiding the real cause.

This converts the fatal throw into a single, actionable error log and keeps the popover holder registered, so the app stays usable and the popover renders if a provider becomes present in the scope. The real cure for an affected app is still to place the providers in the same interactive render mode as the components; the logged message and the installation docs now spell this out.

Same root cause as #11168, #12277, #12283.

Before, the circuit crashes:

fail: ...Circuits.CircuitHost[111] Missing <MudPopoverProvider />
fail: ...Circuits.CircuitHost[111] System.ObjectDisposedException: Cannot access a disposed object.
   at ArrayBuilder`1.GrowBuffer ... at Renderer.ProcessRenderQueue

After, the app keeps running with one actionable log:

fail: MudBlazor.PopoverService[0] Missing <MudPopoverProvider /> in the active render scope, so popovers
cannot be displayed. Add <MudPopoverProvider /> within the same interactive render mode as the components
that use it: in your layout for global interactivity, or on each page for per-page interactivity.
See https://mudblazor.com/getting-started/installation#manual-install-add-components

Fixes #11887

When a popover-based component (picker, select, menu, ...) initializes but no
MudPopoverProvider is subscribed in its render scope, PopoverService threw an
InvalidOperationException from the component's OnInitializedAsync. With per-page
InteractiveServer rendering this is a common misconfiguration (providers in the
static layout, components on an interactive page), and throwing mid-render batch
tears down the circuit so sibling components fault with a cryptic
ObjectDisposedException, hiding the real cause.

Log an actionable error once and keep the holder, so the app stays usable and
the popover renders if a provider is later present in the scope. Also document
global vs per-page provider placement on the installation page.

Fixes MudBlazor#11887
@mudbot mudbot Bot added the bug Unexpected behavior or functionality not working as intended label Jun 26, 2026
@danielchalmers

Copy link
Copy Markdown
Member Author
image

This comment was marked as outdated.

@versile2 versile2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@danielchalmers
danielchalmers merged commit e2ed849 into MudBlazor:dev Jun 28, 2026
10 checks passed
@danielchalmers
danielchalmers deleted the claude/youthful-montalcini-95e54b branch June 28, 2026 16:03
@danielchalmers danielchalmers added refactor Reorganizes code and has no changes to the API or functionality in the main library bug Unexpected behavior or functionality not working as intended and removed bug Unexpected behavior or functionality not working as intended refactor Reorganizes code and has no changes to the API or functionality in the main library labels Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatePicker and DateRange throw ObjectDisposedException inside ExpansionPanel on Blazor Server

3 participants