From ac1f7b22bc3250612dec57d55fc80594ba94e02e Mon Sep 17 00:00:00 2001 From: Ejaaz Khan Date: Tue, 28 Oct 2025 13:53:19 +0530 Subject: [PATCH] fix: duplicate row button visible on cant add rows --- frappe/public/js/frappe/form/grid.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/form/grid.js b/frappe/public/js/frappe/form/grid.js index 959e720806..b433c90549 100644 --- a/frappe/public/js/frappe/form/grid.js +++ b/frappe/public/js/frappe/form/grid.js @@ -87,7 +87,7 @@ export default class Grid { data-action="delete_rows"> ${__("Delete")} - @@ -136,6 +136,7 @@ export default class Grid { this.grid_custom_buttons = this.wrapper.find(".grid-custom-buttons"); this.remove_rows_button = this.grid_buttons.find(".grid-remove-rows"); this.remove_all_rows_button = this.grid_buttons.find(".grid-remove-all-rows"); + this.duplicate_row_button = this.grid_buttons.find(".grid-duplicate-row"); this.setup_allow_bulk_edit(); this.setup_check(); @@ -219,6 +220,7 @@ export default class Grid { this.last_checked_docname = docname; } this.refresh_remove_rows_button(); + this.refresh_duplicate_rows_button(); }); } @@ -340,6 +342,22 @@ export default class Grid { 100 ); + refresh_duplicate_rows_button() { + if (this.df.cannot_add_rows) { + return; + } + + this.duplicate_row_button.toggleClass( + "hidden", + this.wrapper.find(".grid-body .grid-row-check:checked:first").length ? false : true + ); + } + + debounced_duplicate_rows_button = frappe.utils.debounce( + this.refresh_duplicate_rows_button, + 100 + ); + get_selected() { return (this.grid_rows || []) .map((row) => { @@ -531,7 +549,9 @@ export default class Grid { // show, hide buttons to add rows if (this.cannot_add_rows || (this.df && this.df.cannot_add_rows)) { // add 'hidden' to buttons - this.wrapper.find(".grid-add-row, .grid-add-multiple-rows").addClass("hidden"); + this.wrapper + .find(".grid-add-row, .grid-add-multiple-rows, .grid-duplicate-row") + .addClass("hidden"); } else { // show buttons this.wrapper.find(".grid-add-row").removeClass("hidden");