From b98396f4f407e1a2e5d66b6c8b230f3ec7de1903 Mon Sep 17 00:00:00 2001 From: Shrihari Mahabal Date: Mon, 23 Feb 2026 11:54:09 +0530 Subject: [PATCH 1/4] fix: fix: add doc button for long doctype name --- frappe/public/js/frappe/list/list_view.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index d9c6514556..6473db896e 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -291,8 +291,9 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { set_primary_action() { if (this.can_create && !frappe.boot.read_only) { const doctype_name = __(frappe.router.doctype_layout) || __(this.doctype); + const full_label = __("Add {0}", [doctype_name], "Primary action in list view"); const create_button = this.page.set_primary_action( - __("Add {0}", [doctype_name], "Primary action in list view"), + full_label, () => { if (this.settings.primary_action) { this.settings.primary_action(); @@ -304,12 +305,32 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { ); if (frappe.is_mobile()) { create_button.append(__("Add")); + } else { + this._trim_primary_action_if_overflow(create_button, full_label); } } else { this.page.clear_primary_action(); } } + _trim_primary_action_if_overflow(btn, full_label) { + const container = this.page.wrapper.find(".page-head-content")[0]; + if (!container || !btn[0]) return; + const containerRect = container.getBoundingClientRect(); + const btnRect = btn[0].getBoundingClientRect(); + if (btnRect.right > containerRect.right) { + const short_label = __("Add"); + btn.attr("title", full_label) + .tooltip({ delay: { show: 600, hide: 100 }, trigger: "hover" }) + .html( + `${frappe.utils.icon( + "add", + "xs" + )} ` + ); + } + } + make_new_doc() { const doctype = this.doctype; const options = {}; From f1dd3da3f022d12320848ca61bb9ab84d7211d78 Mon Sep 17 00:00:00 2001 From: Shrihari Mahabal Date: Tue, 24 Feb 2026 12:23:41 +0530 Subject: [PATCH 2/4] refactor: remove add icon for add doc button with large doctype name --- frappe/public/js/frappe/list/list_view.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 6473db896e..375cee1d0a 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -291,9 +291,9 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { set_primary_action() { if (this.can_create && !frappe.boot.read_only) { const doctype_name = __(frappe.router.doctype_layout) || __(this.doctype); - const full_label = __("Add {0}", [doctype_name], "Primary action in list view"); + const add_button_label = __("Add {0}", [doctype_name], "Primary action in list view"); const create_button = this.page.set_primary_action( - full_label, + add_button_label, () => { if (this.settings.primary_action) { this.settings.primary_action(); @@ -306,28 +306,23 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { if (frappe.is_mobile()) { create_button.append(__("Add")); } else { - this._trim_primary_action_if_overflow(create_button, full_label); + this._trim_primary_action_if_overflow(create_button, add_button_label); } } else { this.page.clear_primary_action(); } } - _trim_primary_action_if_overflow(btn, full_label) { + _trim_primary_action_if_overflow(btn, add_button_label) { const container = this.page.wrapper.find(".page-head-content")[0]; if (!container || !btn[0]) return; const containerRect = container.getBoundingClientRect(); const btnRect = btn[0].getBoundingClientRect(); if (btnRect.right > containerRect.right) { const short_label = __("Add"); - btn.attr("title", full_label) - .tooltip({ delay: { show: 600, hide: 100 }, trigger: "hover" }) - .html( - `${frappe.utils.icon( - "add", - "xs" - )} ` - ); + btn.attr("title", add_button_label) + .tooltip({ delay: { show: 100, hide: 100 }, trigger: "hover" }) + .html(``); } } From bb23efd4e71a0691fc9af443426eec406b983a31 Mon Sep 17 00:00:00 2001 From: Shrihari Mahabal Date: Tue, 24 Feb 2026 12:52:15 +0530 Subject: [PATCH 3/4] refactor: button inner text change without html manipulation --- frappe/public/js/frappe/list/list_view.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 375cee1d0a..d671ed20b0 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -320,9 +320,11 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const btnRect = btn[0].getBoundingClientRect(); if (btnRect.right > containerRect.right) { const short_label = __("Add"); - btn.attr("title", add_button_label) - .tooltip({ delay: { show: 100, hide: 100 }, trigger: "hover" }) - .html(``); + btn.attr("title", add_button_label).tooltip({ + delay: { show: 100, hide: 100 }, + trigger: "hover", + }); + btn.find("span").text(short_label); } } From 0c80d82b41ba20d7962864004d1edf43146eea36 Mon Sep 17 00:00:00 2001 From: Shrihari Mahabal Date: Tue, 24 Feb 2026 15:19:55 +0530 Subject: [PATCH 4/4] refactor: remove unnecessary tooltip delay and trigger --- frappe/public/js/frappe/list/list_view.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index d671ed20b0..2c28a24063 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -320,10 +320,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { const btnRect = btn[0].getBoundingClientRect(); if (btnRect.right > containerRect.right) { const short_label = __("Add"); - btn.attr("title", add_button_label).tooltip({ - delay: { show: 100, hide: 100 }, - trigger: "hover", - }); + btn.attr("title", add_button_label).tooltip(); btn.find("span").text(short_label); } }