From 02765c98c9b6814e30cc32929706f6f2c12a141c Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Sun, 6 Jun 2021 13:47:17 +0530 Subject: [PATCH] fix: ensure `Page.add_dropdown_item` returns link even if it already exists (#13420) --- frappe/public/js/frappe/ui/page.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frappe/public/js/frappe/ui/page.js b/frappe/public/js/frappe/ui/page.js index e740718ef9..c5ef0d0184 100644 --- a/frappe/public/js/frappe/ui/page.js +++ b/frappe/public/js/frappe/ui/page.js @@ -409,6 +409,9 @@ frappe.ui.Page = class Page { parent.parent().removeClass("hide"); } + let $link = this.is_in_group_button_dropdown(parent, 'li > a.grey-link', label); + if ($link) return $link; + let $li; let $icon = ``; @@ -440,9 +443,8 @@ frappe.ui.Page = class Page { `); } - var $link = $li.find("a").on("click", click); - if (this.is_in_group_button_dropdown(parent, 'li > a.grey-link', label)) return; + $link = $li.find("a").on("click", click); if (standard) { $li.appendTo(parent); @@ -508,7 +510,7 @@ frappe.ui.Page = class Page { let item = $(this).html(); return $(item).attr('data-label') === label; }); - return result.length > 0; + return result.length > 0 && result; } clear_btn_group(parent) {