Skip to content

Commit b4c8c68

Browse files
authored
feat(ModalDialog): add constraints between parameters (#5471)
* refactor: 增加文档注释 * feat: 增加参数约束逻辑 * test: 更新单元测试
1 parent 8eb9f04 commit b4c8c68

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/BootstrapBlazor/Components/Dialog/DialogOption.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ public class DialogOption
3333
/// <summary>
3434
/// 获得/设置 全屏弹窗 默认 None
3535
/// </summary>
36+
/// <remarks>为保证功能正常,设置值后 <see cref="ShowMaximizeButton"/> <seealso cref="ShowResize"/> <seealso cref="IsDraggable"/> 均不可用</remarks>
3637
public FullScreenSize FullScreenSize { get; set; } = FullScreenSize.None;
3738

3839
/// <summary>
3940
/// 获得/设置 是否显示最大化按钮 默认 false 不显示
4041
/// </summary>
42+
/// <remarks>为保证功能正常,设置值为 true 后 <seealso cref="ShowResize"/> <seealso cref="IsDraggable"/> 均不可用</remarks>
4143
public bool ShowMaximizeButton { get; set; }
4244

4345
/// <summary>

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public partial class ModalDialog : IHandlerException
6161
/// <summary>
6262
/// 获得/设置 弹窗大小 默认为 <see cref="FullScreenSize.None"/>
6363
/// </summary>
64+
/// <remarks>为保证功能正常,设置值后 <see cref="ShowMaximizeButton"/> <seealso cref="ShowResize"/> <seealso cref="IsDraggable"/> 均不可用</remarks>
6465
[Parameter]
6566
public FullScreenSize FullScreenSize { get; set; }
6667

@@ -85,6 +86,7 @@ public partial class ModalDialog : IHandlerException
8586
/// <summary>
8687
/// 获得/设置 是否显示最大化按钮 默认为 false
8788
/// </summary>
89+
/// <remarks>为保证功能正常,设置值为 true 后 <seealso cref="ShowResize"/> <seealso cref="IsDraggable"/> 均不可用</remarks>
8890
[Parameter]
8991
public bool ShowMaximizeButton { get; set; }
9092

@@ -329,6 +331,18 @@ protected override void OnParametersSet()
329331
ExportPdfButtonOptions.Icon ??= IconTheme.GetIconByKey(ComponentIcons.TableExportPdfIcon);
330332

331333
MaximizeIconString = MaximizeWindowIcon;
334+
335+
if (FullScreenSize != FullScreenSize.None)
336+
{
337+
ShowMaximizeButton = false;
338+
ShowResize = false;
339+
IsDraggable = false;
340+
}
341+
else if (ShowMaximizeButton)
342+
{
343+
ShowResize = false;
344+
IsDraggable = false;
345+
}
332346
}
333347

334348
/// <summary>

test/UnitTest/Components/DialogTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ await cut.InvokeAsync(() => dialog.Show(new DialogOption()
6464
return Task.CompletedTask;
6565
}
6666
}));
67-
Assert.Contains("<svg", cut.Markup);
67+
68+
// 由于设置了 ShowMaximizeButton 导致 ShowResize 参数失效
69+
Assert.DoesNotContain("<svg", cut.Markup);
6870
Assert.Contains("data-bs-backdrop=\"static\"", cut.Markup);
6971

7072
// 全屏按钮

0 commit comments

Comments
 (0)