mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-04 13:08:23 +08:00
* fix(module: drawer): merge oncancel and onclose (#522) * docs: update drawer docs * fix: drawer service cannot catch onclose on 'x' clicked Co-authored-by: James Yeung <shunjiey@hotmail.com>
This commit is contained in:
parent
360fe0d3c0
commit
f509117d02
@ -53,7 +53,5 @@ namespace AntDesign
|
||||
_drawerRefs.Remove(drawerRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ namespace AntDesign
|
||||
await _service.CloseAsync(this);
|
||||
await OnClose.Invoke(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class DrawerRef
|
||||
@ -36,7 +35,7 @@ namespace AntDesign
|
||||
|
||||
public Func<Task> OnOpen { get; set; }
|
||||
|
||||
public Func<Task> OnClose { get; set; }
|
||||
public Func<DrawerClosingEventArgs, Task> OnClose { get; set; }
|
||||
|
||||
internal DrawerRef(DrawerOptions config)
|
||||
{
|
||||
@ -50,7 +49,7 @@ namespace AntDesign
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开抽屉
|
||||
/// open a drawer
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task OpenAsync()
|
||||
@ -61,25 +60,24 @@ namespace AntDesign
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭抽屉无返回值
|
||||
/// close the drawer without return value
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task CloseAsync()
|
||||
{
|
||||
await _service.CloseAsync(this);
|
||||
if (OnClose != null)
|
||||
await OnClose.Invoke();
|
||||
await OnClose.Invoke(new DrawerClosingEventArgs(false));
|
||||
}
|
||||
|
||||
|
||||
internal async Task HandleOnCancel()
|
||||
{
|
||||
var args = new DrawerClosingEventArgs(false);
|
||||
if (Config.OnCancel != null)
|
||||
if (OnClose != null)
|
||||
{
|
||||
await Config.OnCancel.Invoke(args);
|
||||
await OnClose.Invoke(args);
|
||||
}
|
||||
if (args.Cancel == false)
|
||||
if (!args.Cancel)
|
||||
await _service.CloseAsync(this);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,6 @@ namespace AntDesign
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
internal Task CloseAsync(DrawerRef drawerRef)
|
||||
{
|
||||
if (OnCloseEvent != null)
|
||||
|
@ -48,11 +48,5 @@ namespace AntDesign
|
||||
public int OffsetY { get; set; } = 0;
|
||||
|
||||
public bool Visible { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点击关闭时触发,返回false时,取消关闭动作
|
||||
/// </summary>
|
||||
public Func<DrawerClosingEventArgs, Task> OnCancel { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
_drawerRef = await DrawerService.CreateAsync(options);
|
||||
|
||||
_drawerRef.OnClose = () =>
|
||||
_drawerRef.OnClose = (args) =>
|
||||
{
|
||||
Console.WriteLine("Close Drawer");
|
||||
return Task.CompletedTask;
|
||||
|
@ -50,13 +50,12 @@ Drawer comes very handy.
|
||||
| CreateAsync | create and open an Drawer | `DrawerConfig` | `DrawerRef` |
|
||||
| CreateAsync | create and open an Drawer | `DrawerConfig` , TContentParams | `DrawerRef<R>` |
|
||||
|
||||
### DrawerConfig
|
||||
### DrawerOptions
|
||||
|
||||
| ²ÎÊý | ˵Ã÷ | ÀàÐÍ | ĬÈÏÖµ |
|
||||
| ------------------- | -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | --------- |
|
||||
| Content | The drawer body content. | `OneOf<RenderFragment, string>` | - |
|
||||
| ContentParams | The component inputs the param / The Template context. | `D` | - |
|
||||
| OnCancel | Execute when click on the mask or the upper cancel button (return false to prevent closing) | - |
|
||||
| Closable | Whether a close (x) button is visible on top right of the Drawer dialog or not. | `boolean` | `true` |
|
||||
| MaskClosable | Clicking on the mask (area outside the Drawer) to close the Drawer or not. | `boolean` | `true` |
|
||||
| Mask | Whether to show mask or not. | `boolean` | `true` |
|
||||
|
@ -52,7 +52,6 @@ cover: https://gw.alipayobjects.com/zos/alicdn/7z8NJQhFb/Drawer.svg
|
||||
| ------------------- | -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | --------- |
|
||||
| Content | Drawer body 的内容 | `OneOf<RenderFragment, string>` | - |
|
||||
| ContentParams | 内容组件的输入参数 / Template的 context | `D` | - |
|
||||
| OnCancel | 点击遮罩层或右上角叉时执行,将自动关闭对话框(返回false可阻止关闭) | `() => Promise<any>` `Func<bool?>` | - |
|
||||
| Closable | 是否显示右上角的关闭按钮 | `boolean` | `true` |
|
||||
| MaskClosable | 点击蒙层是否允许关闭 | `boolean` | `true` |
|
||||
| Mask | 是否展示遮罩 | `boolean` | `true` |
|
||||
|
Loading…
Reference in New Issue
Block a user