Skip to content

Commit 4fb2a02

Browse files
fix(ContextMenu): make ContextMenu work on wasm/maui (#7504)
* refactor: 增加线程切换 * chore: 更新依赖脚本到最新 * chore: bump version 10.2.2-beta01 * fix(ContextMenuTrigger): 防止裁剪导致右键菜单定位失败 * chore: bump version 10.2.2-beta02 Co-Authored-By: Marcel Peereboom <40403094+peereflits@users.noreply.github.com> --------- Co-authored-by: Marcel Peereboom <40403094+peereflits@users.noreply.github.com>
1 parent b1b7c0d commit 4fb2a02

7 files changed

Lines changed: 774 additions & 476 deletions

File tree

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.2.1</Version>
4+
<Version>10.2.2-beta02</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Data from "../../modules/data.js"
1+
import Data from "../../modules/data.js"
22
import EventHandler from "../../modules/event-handler.js"
33
import { createPopper, computePosition } from '../../modules/floating-ui.js'
44
import { registerBootstrapBlazorModule } from "../../modules/utility.js"
@@ -36,21 +36,23 @@ export function init(id) {
3636
}
3737

3838
export function show(id, event) {
39-
const cm = Data.get(id)
39+
setTimeout(() => {
40+
const cm = Data.get(id)
4041

41-
if (cm) {
42-
const el = cm.el
43-
const zone = cm.zone
42+
if (cm) {
43+
const el = cm.el
44+
const zone = cm.zone
4445

45-
const body = document.body
46-
body.appendChild(el)
46+
const body = document.body
47+
body.appendChild(el)
4748

48-
if (cm.popper) {
49-
cm.popper()
50-
}
49+
if (cm.popper) {
50+
cm.popper()
51+
}
5152

52-
cm.popper = createPopper(zone, el, () => showContextMenu(zone, el, event))
53-
}
53+
cm.popper = createPopper(zone, el, () => showContextMenu(zone, el, event))
54+
}
55+
}, 0);
5456
}
5557

5658
export function dispose(id) {

src/BootstrapBlazor/Components/ContextMenu/ContextMenuTrigger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -59,7 +59,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
5959
/// <summary>
6060
/// 点击 ContextMenu 菜单项时触发
6161
/// </summary>
62-
/// <returns></returns>
62+
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(MouseEventArgs))]
6363
public Task OnContextMenu(MouseEventArgs args) => ContextMenuZone.OnContextMenu(args, ContextItem);
6464

6565
/// <summary>

0 commit comments

Comments
 (0)