Skip to content

Commit

Permalink
Fix menu position
Browse files Browse the repository at this point in the history
  • Loading branch information
anmcgrath committed May 27, 2024
1 parent bbcbeec commit bc4e9a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/BlazorDatasheet/Menu/MenuShowOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ public class MenuShowOptions
public string Placement { get; set; }
public double Margin { get; set; }
public string Trigger { get; }
public MouseEventArgs Args { get; }
public double ClientX { get; }
public double ClientY { get; }

public MenuShowOptions(string targetId, string placement, double margin, string trigger, MouseEventArgs args)
public MenuShowOptions(string targetId, string placement, double margin, string trigger, double clientX,
double clientY)
{
TargetId = targetId;
Placement = placement;
Margin = margin;
Trigger = trigger;
Args = args;
ClientX = clientX;
ClientY = clientY;
}
}
2 changes: 1 addition & 1 deletion src/BlazorDatasheet/Menu/SheetMenuTarget.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
if (string.IsNullOrEmpty(MenuId))
return;

await MenuService.ShowMenu(MenuId, new MenuShowOptions(TargetId, Placement, Margin, trigger, args), MenuData);
await MenuService.ShowMenu(MenuId, new MenuShowOptions(TargetId, Placement, Margin, trigger, args.ClientX, args.ClientY), MenuData);
}

}
4 changes: 1 addition & 3 deletions src/BlazorDatasheet/wwwroot/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ class MenuService {
showMenuEl(menuEl, options) {
if (this.isActive(menuEl))
return

console.log(options)

// run with set timeout to allow the updated menu to be structured based on context
setTimeout(() => {
Expand All @@ -84,7 +82,7 @@ class MenuService {

menuEl.addEventListener('toggle', onToggle)
if (options.trigger === 'oncontextmenu') {
let rect = new DOMRect(options.args.clientX, options.args.clientY, 1, 1)
let rect = new DOMRect(options.clientX, options.clientY, 1, 1)
this.positionMenu(menuEl, rect, options.margin, options.placement)
} else if (options.targetId) {
let targetEl = document.getElementById(options.targetId)
Expand Down

0 comments on commit bc4e9a0

Please sign in to comment.