Skip to content

Commit

Permalink
fix: remove_custom_button bug (frappe#24199)
Browse files Browse the repository at this point in the history
* fix: remove_custom_button removes menu item

* fix: correct indentation

* correct formatting

* fix: formatting, add yarn to gitignore
  • Loading branch information
safwansamsudeen authored Jan 11, 2024
1 parent af5cc4f commit 0824b8e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ typings/

# Optional npm cache directory
.npm
.yarn

# Optional eslint cache
.eslintcache
Expand Down
21 changes: 20 additions & 1 deletion frappe/public/js/frappe/form/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1456,9 +1456,28 @@ frappe.ui.form.Form = class FrappeForm {
this.custom_buttons = {};
}

//Remove specific custom button by button Label
// Remove specific custom button by button Label
remove_custom_button(label, group) {
this.page.remove_inner_button(label, group);

// Remove actions from menu
delete this.custom_buttons[label];
let menu_item_label = group ? `${group} > ${label}` : label;
let $linkBody = this.page
.is_in_group_button_dropdown(
this.page.menu,
"li > a.grey-link > span",
menu_item_label
)
.parent()
.parent();

if ($linkBody) {
// If last button, remove divider too
let $divider = $linkBody.next(".dropdown-divider");
if ($divider) $divider.remove();
$linkBody.remove();
}
}

scroll_to_element() {
Expand Down

0 comments on commit 0824b8e

Please sign in to comment.