fix(menu): right click menu appears at mouse position
This commit is contained in:
parent
c509494a1a
commit
ae5ff8a0a3
2 changed files with 11 additions and 4 deletions
|
|
@ -3,7 +3,7 @@ frappe.provide("frappe.ui");
|
|||
|
||||
frappe.ui.menu = class ContextMenu {
|
||||
constructor(opts) {
|
||||
this.template = $(`<div class="sidebar-header-menu context-menu" role="menu"></div>`);
|
||||
this.template = $(`<div class="frappe-menu context-menu" role="menu"></div>`);
|
||||
this.menu_items = opts.menu_items;
|
||||
this.name = frappe.utils.get_random(5);
|
||||
this.open_on_left = opts.open_on_left;
|
||||
|
|
@ -94,7 +94,7 @@ frappe.ui.menu = class ContextMenu {
|
|||
parent_menu: this.name,
|
||||
});
|
||||
}
|
||||
show(parent) {
|
||||
show(parent, event) {
|
||||
// this.close_all_other_menu();
|
||||
|
||||
this.make();
|
||||
|
|
@ -135,6 +135,13 @@ frappe.ui.menu = class ContextMenu {
|
|||
});
|
||||
}
|
||||
|
||||
if (event) {
|
||||
this.template.css({
|
||||
left: `${event.clientX}px`,
|
||||
top: `${event.clientY}px`,
|
||||
});
|
||||
}
|
||||
|
||||
this.visible = true;
|
||||
}
|
||||
close_all_other_menu() {
|
||||
|
|
@ -190,7 +197,7 @@ frappe.ui.create_menu = function (opts) {
|
|||
frappe.menu_map[context_menu.name].hide();
|
||||
opts.onHide && opts.onHide(this);
|
||||
} else {
|
||||
frappe.menu_map[context_menu.name].show(this);
|
||||
frappe.menu_map[context_menu.name].show(this, event);
|
||||
opts.onShow && opts.onShow(this);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// can do sizes later on;
|
||||
--menu-width: 200px;
|
||||
}
|
||||
.sidebar-header-menu {
|
||||
.frappe-menu {
|
||||
position: absolute;
|
||||
width: var(--menu-width);
|
||||
padding: 6px;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue