From 093ff2b766f4ba80192d88acfd7f00a83722d751 Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Thu, 1 Dec 2022 11:20:32 +0100
Subject: [PATCH] FIX: Only use the edit-mode fix when actually in edit mode

---
 src/core/js/ext_prop_display.js | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/core/js/ext_prop_display.js b/src/core/js/ext_prop_display.js
index 1de71eae..629e2a4c 100644
--- a/src/core/js/ext_prop_display.js
+++ b/src/core/js/ext_prop_display.js
@@ -180,15 +180,22 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
             const allTypes = await this._getRecordTypes(conf);
             var entities = this.getEntitiesInView();
             this.unhideProperties(entities, conf, allTypes);
-            edit_mode.app.onAfterShowResults = this._unhidePropertiesWrapper(edit_mode.app.onAfterShowResults, conf, allTypes);
+            // If we are in the edit mode, (un)hide properties after ending
+            // the editing of an entity
+            document.body.addEventListener(edit_mode.start_edit.type, (e) => {
+                edit_mode.app.onAfterShowResults = this._unhidePropertiesWrapper(edit_mode.app.onAfterShowResults, conf, allTypes);
+            }, true);
+
         } else {
             this.unhideAllProperties();
-            // also unhide properties when leaving the edit mode
-            // TODO(fspreck): We're lacking a proper state/event here in the
-            // edit mode, so do this on "init", since this is the state to which
-            // the state machine returns after either successfully saving an
-            // entity or canceling the edit.
-            edit_mode.app.onAfterShowResults = this._unhideAllPropertiesWrapper(edit_mode.app.onAfterShowResults);
+            document.body.addEventListener(edit_mode.start_edit.type, (e) => {
+                // also unhide properties when leaving the edit mode
+                // TODO(fspreck): We're lacking a proper state/event here in the
+                // edit mode, so do this on "init", since this is the state to which
+                // the state machine returns after either successfully saving an
+                // entity or canceling the edit.
+                edit_mode.app.onAfterShowResults = this._unhideAllPropertiesWrapper(edit_mode.app.onAfterShowResults);
+            }, true);
         }
     }
 }($, edit_mode, getEntityName, getEntityRole, getPropertyElements, getPropertyName, getUserName, getUserRoles, log.getLogger("ext_prop_display"), load_config, query);
-- 
GitLab