This repository was archived by the owner on Dec 26, 2025. It is now read-only.
Replies: 1 comment
|
For anyone else stumbling across this, here's how I've worked round it. An extension on public static class ModalOptionsExtensions
{
public static string GlobalModalClass => "orbitl-modal-dialog";
/// <summary>
/// Apply a size class to the ModalOptions, retaining the <see cref="GlobalModalClass"/>
/// </summary>
/// <remarks>Cribbed from https://github.com/Blazored/Modal/blob/main/src/Blazored.Modal/BlazoredModalInstance.razor.cs</remarks>
/// <param name="options"></param>
/// <param name="size"></param>
/// <returns></returns>
public static ModalOptions ApplySize(this ModalOptions options, ModalSize size)
{
var sizeCss = size switch
{
ModalSize.Small => "size-small",
ModalSize.Medium => "size-medium",
ModalSize.Large => "size-large",
ModalSize.ExtraLarge => "size-extra-large",
ModalSize.Automatic => "size-automatic",
ModalSize.Custom => throw new InvalidOperationException(
"Don't use this method to set custom size - apply this directly in CSS instead."),
_ => "size-medium"
};
options.Class = $"{GlobalModalClass} {sizeCss}";
return options;
}
}My default class uses the shared magic string in @using orbitl.web.user.Models.Extensions
<CascadingBlazoredModal DisableBackgroundCancel="true" Class="@ModalOptionsExtensions.GlobalModalClass">
<CascadingAuthenticationState>
...And it is used like this: private async Task ShowUploadModal()
{
var options = new ModalOptions()
.ApplySize(ModalSize.Small);
var uploadModal = ModalService.Show<UploadNewBaselineNew>("Upload", options);
// ... |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
First off - great set of projects, and much appreciate everyone's efforts.
I'm in the process of R&D'ing blazored.modal to replace our in-house clunky semi-bootstrap option and love all the flexibility, especially the easy of adding a custom CSS class to pick up our default styling.
I was a little perplexed, though, to find that ModalOptions.Size stopped being honoured if we specify a custom CSS class, and it looks like a conscious design decision, here:
Modal/src/Blazored.Modal/BlazoredModalInstance.razor.cs
Line 268 in 92db30b
I can work around this by supplying the original size class, albeit I also have to include my globally-set modal class:
Rather than go straight to logging an issue I thought I'd ask here whether there was any appetite to change or toggle this behaviour?
If there is some appetite and we can agree an approach here, I'm happy to produce a PR.
All reactions