Skip to content

Commit 7567909

Browse files
authored
feat(Dialog): add IsHidePreviousDialog parameter (#5866)
* refactor: 增加 IsKeepPreviousDialog 配置项 * feat: 增加 modal-multiple 样式 * refactor: 更改参数名称 * refactor: 更新样式 * refactor: 增加 show 参数 * chore: bump version 9.5.11-beta01
1 parent ad7cafc commit 7567909

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.5.10</Version>
4+
<Version>9.5.11-beta01</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Dialog/Dialog.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@inherits BootstrapComponentBase
33

44
<Modal @ref="_modal" IsBackdrop="_isBackdrop" IsKeyboard="@_isKeyboard" IsFade="@_isFade"
5-
OnShownAsync="@_onShownAsync" OnCloseAsync="@_onCloseAsync">
5+
OnShownAsync="@_onShownAsync" OnCloseAsync="@_onCloseAsync" class="@ClassString">
66
@for (var index = 0; index < DialogParameters.Keys.Count; index++)
77
{
88
@RenderDialog(index, DialogParameters.Keys.ElementAt(index))

src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public partial class Dialog : IDisposable
2929
private bool _isBackdrop = false;
3030
private bool? _isFade = null;
3131

32+
private string? ClassString => CssBuilder.Default()
33+
.AddClass("modal-multiple", DialogParameters.Count > 1)
34+
.AddClass("show", DialogParameters.Count > 0)
35+
.Build();
36+
3237
/// <summary>
3338
/// <inheritdoc/>
3439
/// </summary>

src/BootstrapBlazor/Components/Dialog/DialogOption.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ public class DialogOption
197197
/// </summary>
198198
public ExportPdfButtonOptions? ExportPdfButtonOptions { get; set; }
199199

200+
/// <summary>
201+
/// Gets or sets whether to hide the previous dialog when opening a new one, default is false
202+
/// </summary>
203+
public bool IsHidePreviousDialog { get; set; }
204+
200205
/// <summary>
201206
/// Method to close the dialog
202207
/// </summary>
@@ -220,6 +225,7 @@ public Dictionary<string, object> ToAttributes()
220225
[nameof(ModalDialog.FullScreenSize)] = FullScreenSize,
221226
[nameof(ModalDialog.IsCentered)] = IsCentered,
222227
[nameof(ModalDialog.IsScrolling)] = IsScrolling,
228+
[nameof(ModalDialog.IsHidePreviousDialog)] = IsHidePreviousDialog,
223229
[nameof(ModalDialog.ShowCloseButton)] = ShowCloseButton,
224230
[nameof(ModalDialog.ShowSaveButton)] = ShowSaveButton,
225231
[nameof(ModalDialog.ShowHeaderCloseButton)] = ShowHeaderCloseButton,

src/BootstrapBlazor/Components/Modal/Modal.razor.scss

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.is-draggable .modal-header {
1+
.is-draggable .modal-header {
22
cursor: pointer;
33
}
44

@@ -70,6 +70,24 @@
7070
width: 100vw !important;
7171
}
7272

73+
.modal-multiple .modal-dialog {
74+
position: fixed;
75+
inset: 0;
76+
77+
&:last-child:before {
78+
content: "";
79+
position: fixed;
80+
inset: 0;
81+
background-color: #000;
82+
opacity: 0.3;
83+
pointer-events: auto;
84+
}
85+
}
86+
87+
.modal-multiple ~ .modal-backdrop {
88+
display: none;
89+
}
90+
7391
@media print {
7492
.bb-printview-open {
7593
overflow: auto !important;

src/BootstrapBlazor/Components/Modal/ModalDialog.razor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public partial class ModalDialog : IHandlerException
2525
.AddClass("modal-fullscreen", MaximizeStatus)
2626
.AddClass("is-draggable", IsDraggable)
2727
.AddClass("is-draggable-center", IsCentered && IsDraggable && _firstRender)
28-
.AddClass("d-none", !IsShown)
28+
.AddClass("d-none", IsHidePreviousDialog && !IsShown)
2929
.AddClass(Class, !string.IsNullOrEmpty(Class))
3030
.AddClassFromAttributes(AdditionalAttributes)
3131
.Build();
@@ -78,6 +78,12 @@ public partial class ModalDialog : IHandlerException
7878
[Parameter]
7979
public bool IsScrolling { get; set; }
8080

81+
/// <summary>
82+
/// Gets or sets whether to hide the previous dialog when opening a new one, default is false
83+
/// </summary>
84+
[Parameter]
85+
public bool IsHidePreviousDialog { get; set; }
86+
8187
/// <summary>
8288
/// 获得/设置 是否可以拖拽弹窗 默认 false 不可以拖动
8389
/// </summary>

0 commit comments

Comments
 (0)