From 07249fe17b844261bf553a12b100e0dbdb8bd5a1 Mon Sep 17 00:00:00 2001 From: Corentin Forler Date: Mon, 19 Aug 2024 14:22:52 +0200 Subject: [PATCH] fix(form): Fix Geolocation/Signature fields in tabbed layout --- frappe/public/js/frappe/form/form.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frappe/public/js/frappe/form/form.js b/frappe/public/js/frappe/form/form.js index cd15afbfbd..9803d85ca9 100644 --- a/frappe/public/js/frappe/form/form.js +++ b/frappe/public/js/frappe/form/form.js @@ -2163,6 +2163,18 @@ frappe.ui.form.Form = class FrappeForm { } this.script_manager.trigger("on_tab_change"); + + // When switching tabs, we should tell fields to update their display if needed (e.g. Geolocation and Signature fields). + // This is done using the already existing on_section_collapse optional method. + let in_tab = false; + for (const df of this.layout.fields) { + const field = this.get_field(df.fieldname); + if (df?.fieldtype == "Tab Break") { + in_tab = df === tab?.df; + } else if (typeof field?.on_section_collapse == "function") { + field.on_section_collapse(!in_tab); // hide = !in_tab + } + } } get_active_tab() {