diff --git a/components/modal/config/DialogOptions.cs b/components/modal/config/DialogOptions.cs
index e0a52524..d3a436c2 100644
--- a/components/modal/config/DialogOptions.cs
+++ b/components/modal/config/DialogOptions.cs
@@ -99,6 +99,11 @@ namespace AntDesign
///
public RenderFragment RestoreBtnIcon { get; set; } = DefaultRestoreIcon;
+ ///
+ /// Maximize the dialog during component initialization, and it will ignore the Maximizable value.
+ ///
+ public bool DefaultMaximized { get; set; } = false;
+
#region internal
diff --git a/components/modal/config/ModalOptions.cs b/components/modal/config/ModalOptions.cs
index 97bc49c9..1f5eb8d1 100644
--- a/components/modal/config/ModalOptions.cs
+++ b/components/modal/config/ModalOptions.cs
@@ -134,6 +134,12 @@ namespace AntDesign
///
public RenderFragment RestoreBtnIcon { get; set; } = DialogOptions.DefaultRestoreIcon;
+ ///
+ /// Maximize the Modal during component initialization, and it will ignore the Maximizable value.
+ ///
+ [Parameter]
+ public bool DefaultMaximized { get; set; } = false;
+
#region internal
internal async Task DefaultOnCancelOrOk(MouseEventArgs e)
diff --git a/components/modal/core/Dialog.razor.cs b/components/modal/core/Dialog.razor.cs
index 9db98613..0fc30647 100644
--- a/components/modal/core/Dialog.razor.cs
+++ b/components/modal/core/Dialog.razor.cs
@@ -261,17 +261,24 @@ namespace AntDesign
{
if (_modalStatus == ModalStatus.Default)
{
- _modalStatus = ModalStatus.Max;
+ SetModalStatus(ModalStatus.Max);
}
else
{
- _modalStatus = ModalStatus.Default;
+ SetModalStatus(ModalStatus.Default);
}
- _wrapStyle = CalcWrapStyle();
- _modalStyle = CalcModalStyle();
return Task.CompletedTask;
}
+
+ private void SetModalStatus(ModalStatus modalStatus)
+ {
+ _modalStatus = modalStatus;
+ _wrapStyle = CalcWrapStyle();
+ _modalStyle = CalcModalStyle();
+ }
+
+
#region control show and hide class name and style
///
@@ -387,6 +394,8 @@ namespace AntDesign
#region override
+ private bool _hasRendered = false;
+
///
///
///
@@ -396,10 +405,14 @@ namespace AntDesign
//Reduce one rendering when showing and not destroyed
if (Visible)
{
+ if (!_hasRendered && Config.DefaultMaximized)
+ {
+ _hasRendered = true;
+ SetModalStatus(ModalStatus.Max);
+ }
if (!_hasDestroy)
{
Show();
- //await InvokeStateHasChangedAsync();
}
else
{
diff --git a/components/modal/modalDialog/Modal.razor.cs b/components/modal/modalDialog/Modal.razor.cs
index e6777192..576044ef 100644
--- a/components/modal/modalDialog/Modal.razor.cs
+++ b/components/modal/modalDialog/Modal.razor.cs
@@ -16,7 +16,7 @@ namespace AntDesign
#region Parameter
///
- ///
+ ///
///
[Parameter]
public ModalRef ModalRef { get; set; }
@@ -24,7 +24,7 @@ namespace AntDesign
///
/// Specify a function that will be called when modal is closed
///
- [Parameter]
+ [Parameter]
public Func AfterClose { get; set; }
///
@@ -46,7 +46,7 @@ namespace AntDesign
public bool Centered { get; set; }
///
- /// Whether a close (x) button is visible on top right of the modal dialog or not
+ /// Whether a close (x) button is visible on top right of the modal dialog or not
///
[Parameter]
public bool Closable { get; set; } = true;
@@ -82,7 +82,7 @@ namespace AntDesign
public bool DestroyOnClose { get; set; }
///
- /// Footer content, set as Footer=null when you don't need default buttons
+ /// Footer content, set as Footer=null when you don't need default buttons
///
[Parameter]
public OneOf? Footer { get; set; } = DialogOptions.DefaultFooter;
@@ -94,7 +94,7 @@ namespace AntDesign
public ElementReference? GetContainer { get; set; } = null;
///
- /// Whether support press esc to close
+ /// Whether support press esc to close
///
[Parameter]
public bool Keyboard { get; set; } = true;
@@ -106,13 +106,13 @@ namespace AntDesign
public bool Mask { get; set; } = true;
///
- /// Whether to close the modal dialog when the mask (area outside the modal) is clicked
+ /// Whether to close the modal dialog when the mask (area outside the modal) is clicked
///
[Parameter]
public bool MaskClosable { get; set; } = true;
///
- /// Style for modal's mask element
+ /// Style for modal's mask element
///
[Parameter]
public string MaskStyle { get; set; }
@@ -143,10 +143,10 @@ namespace AntDesign
[Parameter]
public RenderFragment TitleTemplate { get; set; } = null;
- #endregion
+ #endregion title
///
- /// Whether the modal dialog is visible or not
+ /// Whether the modal dialog is visible or not
///
[Parameter]
public bool Visible { get; set; }
@@ -169,7 +169,7 @@ namespace AntDesign
}
///
- /// The class name of the container of the modal dialog
+ /// The class name of the container of the modal dialog
///
[Parameter]
public string WrapClassName { get; set; }
@@ -181,31 +181,31 @@ namespace AntDesign
public int ZIndex { get; set; } = 1000;
///
- /// Specify a function that will be called when a user clicks mask, close button on top right or Cancel button
+ /// Specify a function that will be called when a user clicks mask, close button on top right or Cancel button
///
[Parameter]
public EventCallback OnCancel { get; set; }
///
- /// Specify a function that will be called when a user clicks the OK button
+ /// Specify a function that will be called when a user clicks the OK button
///
[Parameter]
public EventCallback OnOk { get; set; }
///
- /// The OK button props
+ /// The OK button props
///
[Parameter]
public ButtonProps OkButtonProps { get; set; }
///
- /// The Cancel button props
+ /// The Cancel button props
///
[Parameter]
public ButtonProps CancelButtonProps { get; set; }
///
- ///
+ ///
///
[Parameter]
public RenderFragment ChildContent { get; set; }
@@ -245,6 +245,12 @@ namespace AntDesign
[Parameter]
public RenderFragment RestoreBtnIcon { get; set; } = DialogOptions.DefaultRestoreIcon;
+ ///
+ /// Maximize the Modal during component initialization, and it will ignore the Maximizable value.
+ ///
+ [Parameter]
+ public bool DefaultMaximized { get; set; } = false;
+
#endregion Parameter
#pragma warning disable 649
@@ -326,6 +332,7 @@ namespace AntDesign
Maximizable = Maximizable,
MaximizeBtnIcon = MaximizeBtnIcon,
RestoreBtnIcon = RestoreBtnIcon,
+ DefaultMaximized = DefaultMaximized
};
return options;
@@ -362,6 +369,6 @@ namespace AntDesign
await InvokeAsync(StateHasChanged);
}
- #endregion
+ #endregion Sustainable Dialog
}
}
diff --git a/components/modal/modalDialog/ModalContainer.razor b/components/modal/modalDialog/ModalContainer.razor
index f5202cbb..d240fe7b 100644
--- a/components/modal/modalDialog/ModalContainer.razor
+++ b/components/modal/modalDialog/ModalContainer.razor
@@ -5,78 +5,43 @@
@foreach (ModalRef modalRef in _modalRefs)
{
var options = modalRef.Config;
- if (options.TitleTemplate != null)
- {
-
- @options.Content
-
- }
- else
- {
-
- @options.Content
-
- }
+
+
+ @options.Content
+
}
\ No newline at end of file
diff --git a/site/AntDesign.Docs/Demos/Components/Modal/demo/Maxable.razor b/site/AntDesign.Docs/Demos/Components/Modal/demo/Maxable.razor
index f2ba3c6d..18fa185f 100644
--- a/site/AntDesign.Docs/Demos/Components/Modal/demo/Maxable.razor
+++ b/site/AntDesign.Docs/Demos/Components/Modal/demo/Maxable.razor
@@ -5,7 +5,8 @@
Visible="@_visible"
OnOk="@HandleOk"
OnCancel="@HandleCancel"
- Maximizable="@true">
+ Maximizable="@true"
+ DefaultMaximized="@true">
Some contents...
Some contents...
Some contents...
diff --git a/site/AntDesign.Docs/Demos/Components/Modal/demo/maxable.md b/site/AntDesign.Docs/Demos/Components/Modal/demo/maxable.md
index 5d3e3743..db136213 100644
--- a/site/AntDesign.Docs/Demos/Components/Modal/demo/maxable.md
+++ b/site/AntDesign.Docs/Demos/Components/Modal/demo/maxable.md
@@ -7,14 +7,19 @@ title:
## zh-CN
-允许Modal在浏览器内最大化。
+允许Modal在浏览器内最大化.
+`Maximizable`参数将会展示 Modal 最大化的按钮;`DefaultMaximized` 参数可以控制在 Modal 初始化的时候最大化。
+`Maximizable` 和 `DefaultMaximized` 并不相互耦合,即使 `Maximizable=false`, `DefaultMaximized=true` 也会保证 Modal 初始化的时候最大化。
注意:
1. 如果`Draggable`为true,恢复大小的时候将会重置位置
2. 当Modal最大化的时候被关闭,再次显示的时候会保持最大化的样子
## en-US
-Allow Modal to maximize within the browser.
+Allow Modal to maximize within the browser.
+The `Maximizable` parameter will display the button for maximizing Modal, and the `DefaultMaximized` parameter can control the maximization during Modal initialization.
+`Maximizable` and `DefaultMaximized` are not coupled with each other. Even if `Maximizable=false` and `DefaultMaximized=true` will ensure that the Modal is maximized during initialization.
+
Note:
1. If `Draggable` is true, the position will be reset when the size is restored
2. It is turned off when the Modal is maximized, and it will remain maximized when it is displayed again
diff --git a/site/AntDesign.Docs/Demos/Components/Modal/doc/index.en-US.md b/site/AntDesign.Docs/Demos/Components/Modal/doc/index.en-US.md
index e81ad460..10cc94e2 100644
--- a/site/AntDesign.Docs/Demos/Components/Modal/doc/index.en-US.md
+++ b/site/AntDesign.Docs/Demos/Components/Modal/doc/index.en-US.md
@@ -49,7 +49,7 @@ When requiring users to interact with the application, but without jumping to a
| Maximizable | Whether to display the maximize button | bool | false |
| MaximizeBtnIcon | The icon of the maximize button when the modal is in normal state | RenderFragment | fullscreen |
| RestoreBtnIcon | The icon of the maximize button when the modal is in maximized state | RenderFragment | fullscreen-exit |
-
+| DefaultMaximized | Modal is maximized at initialization | bool | false |
#### Note
diff --git a/site/AntDesign.Docs/Demos/Components/Modal/doc/index.zh-CN.md b/site/AntDesign.Docs/Demos/Components/Modal/doc/index.zh-CN.md
index 61ac0299..7493eb3b 100644
--- a/site/AntDesign.Docs/Demos/Components/Modal/doc/index.zh-CN.md
+++ b/site/AntDesign.Docs/Demos/Components/Modal/doc/index.zh-CN.md
@@ -52,6 +52,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/3StSdUlSH/Modal.svg
| Maximizable | 是否显示最大化按钮 | bool | false |
| MaximizeBtnIcon | Modal在正常状态下的最大化按钮icon | RenderFragment | fullscreen |
| RestoreBtnIcon | Modal在最大化状态下的还原按钮icon | RenderFragment | fullscreen-exit |
+| DefaultMaximized | Modal 在初始化时即为最大化状态 | bool | false |
#### 注意