-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Bug type
Component
Component name
MudPopoverProvider
What happened?
We have a MudDialog component which contains, among other inputs, a MudSelect to allow the user to select from a dropdown list. This is working fine at runtime if we just include MudThemeProvider in the MainLayour.razor.
However, when we try to unit test our component containing the MudSelect, we are not seeing any option items rendered for selection unless we include MudPopoverProvider in the component under test itself. By including this provider, this allows the unit tests to pass but at runtime we see this error in the console:
"System.InvalidOperationException: Duplicate MudPopoverProvider detected. Please ensure there is only one provider, or disable this warning with PopoverOptions.ThrowOnDuplicateProvider."
We followed the advice documented in the code itself and error message by setting the PopoverOptions.ThrowOnDuplicateProvider to false during configuration in Program.cs however this seems to have had no effect as we're still seeing the exception at runtime
builder.Services.AddMudServices(options =>
{
options.PopoverOptions.ThrowOnDuplicateProvider = false;
});
Reproduction:
This can be replicated through the MudBlazor.Docs project itself by simply including the SelectTest2 component (which has the MudPopoverProvider included) in the SelectVariantsExample.razor and setting config.PopoverOptions.ThrowOnDuplicateProvider to false in the TryAddDocsViewServices() method in MudBlazor.Docs.Server.
When the Select docs page is then loaded, there is an exception banner and the console shows the same exception as above.
It looks like the unit tests fake out the components under test as they include the MudPopoverProvider.
Expected behavior
Honestly not sure, could be able to include PopoverProvider in the individual components where a MudSelect component is used but this then doesn't throw a run-time error, even when ThrowOnDuplicate is set to false... this could cause errors though at runtime with multiple providers not tracking properly? Probably really shouldn't need to manually include this MudPopoverProvider at all?
Reproduction link
Reproduction steps
- Include MudThemeProvider in MainLayout
- Use MudSelect in a component with one or more options
- Check that MudSelect is working at runtime
- Then attempt to unit test the component and try to select an option
- Option items aren't for selection in the unit test
- Include MudPopoverProvider in the component
- Option items are rendered for selection in the unit test
- Run the website and see the exception on the page
- Attempt to set PopoverOptions Throw to false
- Run the website and see the exception on the page
Relevant log output
No response
Version (bug)
6.0.15
Version (working)
No response
What browsers are you seeing the problem on?
Chrome
On what operating system are you experiencing the issue?
Windows
Pull Request
- I would like to do a Pull Request
Code of Conduct
- I agree to follow this project's Code of Conduct