!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:
Argo 2022-11-24 16:22:52 +00:00
parent e9401fe431
commit 60a40fd00f
4 changed files with 25 additions and 12 deletions

View File

@ -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'">

View File

@ -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)
}
}

View File

@ -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;

View File

@ -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