refactor: remove add icon for add doc button with large doctype name

This commit is contained in:
Shrihari Mahabal 2026-02-24 12:23:41 +05:30
parent b98396f4f4
commit f1dd3da3f0

View file

@ -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"
)} <span class="hidden-xs"> ${short_label} </span>`
);
btn.attr("title", add_button_label)
.tooltip({ delay: { show: 100, hide: 100 }, trigger: "hover" })
.html(`<span class="hidden-xs"> ${short_label} </span>`);
}
}