From cb3205e5698802cfefc9bbc7721cf07cff59d5c9 Mon Sep 17 00:00:00 2001 From: Maharshi Patel Date: Tue, 5 Dec 2023 23:31:58 +0530 Subject: [PATCH] fix: only update primary action if it is new action is provided Currently, the primary action is updated even if the new action is None. This breaks some old code that relies on the primary action being None when no action is provided. (used to update primary action label) I changed the code to only update the primary action if the new action function is provided --- frappe/public/js/frappe/ui/dialog.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frappe/public/js/frappe/ui/dialog.js b/frappe/public/js/frappe/ui/dialog.js index b2ac9a7769..515b693482 100644 --- a/frappe/public/js/frappe/ui/dialog.js +++ b/frappe/public/js/frappe/ui/dialog.js @@ -180,11 +180,9 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup { this.footer.removeClass("hide"); this.has_primary_action = true; var me = this; - return this.get_primary_btn() - .removeClass("hide") - .html(label) - .off("click") - .on("click", function () { + const primary_btn = this.get_primary_btn().removeClass("hide").html(label); + if (typeof click == "function") { + primary_btn.off("click").on("click", function () { me.primary_action_fulfilled = true; // get values and send it // as first parameter to click callback @@ -193,6 +191,8 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup { if (!values) return; click && click.apply(me, [values]); }); + } + return primary_btn; } set_secondary_action(click) {