diff --git a/frappe/public/js/frappe/form/info_card.js b/frappe/public/js/frappe/form/info_card.js index fc827f29b1..5394d4f664 100644 --- a/frappe/public/js/frappe/form/info_card.js +++ b/frappe/public/js/frappe/form/info_card.js @@ -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(); + } + }); } } diff --git a/frappe/public/js/frappe/ui/sidebar/sidebar_card.js b/frappe/public/js/frappe/ui/sidebar/sidebar_card.js index aa28b8d145..40198feee8 100644 --- a/frappe/public/js/frappe/ui/sidebar/sidebar_card.js +++ b/frappe/public/js/frappe/ui/sidebar/sidebar_card.js @@ -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) {