ant-design-blazor/components/drawer/Drawer.razor
trafium 9080423ee4
fix(module: drawer): Add type="button" to Drawer close button. (#3233)
* Fix: Add `type="button"` to Drawer close button.

Without this close button triggers form submit if drawer is defined within form.

* Fix tests

---------

Co-authored-by: James Yeung <shunjiey@hotmail.com>
Co-authored-by: Dmitri Afanasjev <dafanasjev@microsoft.com>
2023-05-06 08:57:57 +08:00

56 lines
2.4 KiB
C#

@namespace AntDesign
@inherits AntDomComponentBase
<CascadingValue Value="@($"#ant-drawer-wrap_{Id} .ant-drawer-wrapper-body")" Name="PopupContainerSelector">
<div class="@ClassMapper.Class" @ref="@Ref" style="@_drawerStyle @InnerZIndexStyle @Style" id="@Id">
@if (Mask && Visible)
{
<div class="ant-drawer-mask" @onclick="MaskClick" style="@MaskStyle"></div>
}
<div class="ant-drawer-content-wrapper @WrapClassName " style="@WrapperStyle" id="@($"ant-drawer-wrap_{Id}")">
<div class="ant-drawer-content">
<div class="ant-drawer-wrapper-body" style="@(IsLeftOrRight?"height:100%":"")">
@if (_title.Value != null || Closable)
{
<div class="@TitleClassMapper.Class" style="@HeaderStyle">
@if (_title.Value != null)
{
<div class="ant-drawer-title">
@if (TitleTemplate != null)
{
@TitleTemplate
}
@if (!string.IsNullOrEmpty(TitleString))
{
@((MarkupString)TitleString)
}
</div>
}
@if (Closable)
{
<button @onclick="_=>CloseClick()" type="button" aria-label="Close" class="ant-drawer-close">
<Icon Type="close" />
</button>
}
</div>
}
<div class="ant-drawer-body" style="@BodyStyle">
@if (ContentTemplate != null)
{
@ContentTemplate
}
@if (!string.IsNullOrEmpty(ContentString))
{
@((MarkupString)ContentString)
}
@ChildContent
</div>
</div>
</div>
@if (Handler != null)
{
@Handler
}
</div>
</div>
</CascadingValue>