fix(ux): hide card if clicked outside

This commit is contained in:
sokumon 2026-02-08 15:26:42 +05:30
parent 2ae0da7903
commit 4040841fd1
2 changed files with 16 additions and 5 deletions

View file

@ -52,5 +52,10 @@ export class InfoCard {
event.preventDefault();
me.card.toggle();
});
$(document).on("click", function (e) {
if (!e.originalEvent.composedPath().includes(me.label_area)) {
me.card.hide();
}
});
}
}

View file

@ -38,14 +38,20 @@ frappe.ui.SidebarCard = class SidebarCard {
}
toggle() {
if (this.display) {
this.display = false;
this.parent.removeAttr("data-show");
this.hide();
} else {
this.display = true;
this.parent.attr("data-show", "");
this.popper.update();
this.show();
}
}
hide() {
this.display = false;
this.parent.removeAttr("data-show");
}
show() {
this.display = true;
this.parent.attr("data-show", "");
this.popper.update();
}
setup_primary_action() {
const me = this;
this.card.find(".sidebar-card-button").on("click", function (event) {