Skip to content

Commit

Permalink
fix: only update primary action if it is new action is provided
Browse files Browse the repository at this point in the history
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

(cherry picked from commit cb3205e)
  • Loading branch information
maharshivpatel authored and mergify[bot] committed Dec 6, 2023
1 parent c18b3ac commit 0de2b28
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frappe/public/js/frappe/ui/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 0de2b28

Please sign in to comment.