mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 21:50:05 +08:00
!3560 fix(#I63126): can't close Modal dialog when enable drag function in mobile mode
* chore: bump version 7.0.8-beta01 * test: 修复单元测试 * fix: 修复 Modal 弹窗开启拖动功能无法关闭问题
This commit is contained in:
parent
e9401fe431
commit
60a40fd00f
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>7.0.7</Version>
|
||||
<Version>7.0.8-beta01</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
|
||||
|
@ -196,16 +196,19 @@ const setIndeterminate = (object, state) => {
|
||||
|
||||
const drag = (element, start, move, end) => {
|
||||
const handleDragStart = e => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
document.addEventListener('mousemove', handleDragMove)
|
||||
document.addEventListener('touchmove', handleDragMove)
|
||||
document.addEventListener('mouseup', handleDragEnd)
|
||||
document.addEventListener('touchend', handleDragEnd)
|
||||
|
||||
let notDrag = false
|
||||
if (isFunction(start)) {
|
||||
start(e)
|
||||
notDrag = start(e) || false
|
||||
}
|
||||
|
||||
if (!notDrag) {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
document.addEventListener('mousemove', handleDragMove)
|
||||
document.addEventListener('touchmove', handleDragMove)
|
||||
document.addEventListener('mouseup', handleDragEnd)
|
||||
document.addEventListener('touchend', handleDragEnd)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,9 @@ export class Modal extends BlazorComponent {
|
||||
this._header = this._dialog.querySelector('.modal-header')
|
||||
drag(this._header,
|
||||
e => {
|
||||
if (e.srcElement.closest('.modal-header-buttons')) {
|
||||
return true
|
||||
}
|
||||
this._originX = e.clientX || e.touches[0].clientX;
|
||||
this._originY = e.clientY || e.touches[0].clientY;
|
||||
|
||||
|
@ -269,6 +269,7 @@ public class AutoFillTest : BootstrapBlazorTestBase
|
||||
[Fact]
|
||||
public void ValidateForm_Ok()
|
||||
{
|
||||
var v = "";
|
||||
IEnumerable<string> items = new List<string>() { "test1", "test2" };
|
||||
var cut = Context.RenderComponent<ValidateForm>(pb =>
|
||||
{
|
||||
@ -276,14 +277,20 @@ public class AutoFillTest : BootstrapBlazorTestBase
|
||||
pb.AddChildContent<AutoFill<string>>(pb =>
|
||||
{
|
||||
pb.Add(a => a.Items, items);
|
||||
pb.Add(a => a.OnCustomFilter, key =>
|
||||
{
|
||||
v = key;
|
||||
return Task.FromResult(items);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Trigger js invoke
|
||||
var comp = cut.FindComponent<AutoFill<string>>().Instance;
|
||||
comp.TriggerOnChange("v");
|
||||
|
||||
Assert.Equal("v", comp.Value);
|
||||
var input = cut.Find("input");
|
||||
cut.InvokeAsync(() => input.KeyUp("Enter"));
|
||||
Assert.Equal("v", v);
|
||||
}
|
||||
|
||||
class AutoFillNullStringMock
|
||||
|
Loading…
Reference in New Issue
Block a user